assembly search path

D

DeveloperX

I've a shared add in written in C#. It works on the dev machine fine
with VS2003 installed, but not on a machine without VS.
We've been doing lots of research, and my current concern (discovered
using filemon) is that it looks in the app base directory. In this
case the app base directory is the home of Excel.exe. I can load my
application specific portion of the add into a seperate appdomain and
set the dll path from there, but then I have to marshal the Excel
application object across, and I have yet to figure out (try) that. It
seems unnecessary as it all works a treat on the dev machine. Both dev
and test machine have admin rights.

So question one: Is there a way to encourage my add in to look in its
directory, not the app's directory for the DLL's?
question two: what is different between a machine with VS installed
and one without (barring the obvious)?

Cheers
 
S

Stanimir Stoyanov

So question one: Is there a way to encourage my add in to look in its
directory, not the app's directory for the DLL's?

You can make use of the AppDomain.AssemblyResolve [1] event in your default
AppDomain to check whether or not the current request is for loading your
assemblies, and if so, call Assembly.LoadFile [2] with the full path
instead.
question two: what is different between a machine with VS installed
and one without (barring the obvious)?
Virtually none. However, you may have several additional assembly
directories appended to the PATH environment variable which are used as
search paths.

[1]
http://msdn2.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx
[2]
http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.loadfile.aspx

Best Regards,
Stanimir Stoyanov
www.stoyanoff.info | www.aeroxp.org
 
D

DeveloperX

So question one: Is there a way to encourage my add in to look in its
directory, not the app's directory for the DLL's?

You can make use of the AppDomain.AssemblyResolve [1] event in your default
AppDomain to check whether or not the current request is for loading your
assemblies, and if so, call Assembly.LoadFile [2] with the full path
instead.
question two: what is different between a machine with VS installed
and one without (barring the obvious)?

Virtually none. However, you may have several additional assembly
directories appended to the PATH environment variable which are used as
search paths.

[1]http://msdn2.microsoft.com/en-us/library/system.appdomain.assemblyres...
[2]http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.l...

Best Regards,
Stanimir Stoyanovwww.stoyanoff.info|www.aeroxp.org

Cheers Stanimir, that should do the trick nicely!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top