Groups | Blog | Home
all groups > dotnet clr > october 2004 >

dotnet clr : Assembly.LoadFrom problems called from WindowsService


David Levine
10/28/2004 4:43:28 PM
What is the appdomain's base directory that the window service is running
in, and what is the location of the assembly you are loading using LoadFrom?
If the assembly is not located in the same directory, or a subdirectory
below the appbase, then the runtime cannot automatically resolve the
reference.

You can subscribe to the appdomain's AssemblyResolve event to manually
locate dependencies for the runtime.

[quoted text, click to view]

Chris Lewis
10/28/2004 10:10:14 PM
Hi,

I have a Windows Service that processes MSMQ messages and dynamically
instantiates 'Message Processor' components according to the message type.

I use the Assembly.LoadFrom(<assembly path>) call to load the appropriate
assembly from its path. All works fine as far as the assembly itself goes,
but I get the FileNotFoundException for any dependencies. I know that
LoadFrom should add the path of the dynamically loaded assembly to the list
of paths searched for dependencies - but it's not happening for me. If I
drop the required assemblies into the Windows Service .exe directory all is
fine (even though the dynamic assembly itself is not there).

Please help - is there something different about Windows Services that means
that this mechanism doesn't work?

Thanks, in anticipation.

Chris Lewis

David Levine
10/29/2004 3:24:19 AM
That will work if the assembly is located in a subdirectory below the
application base directory. Also, that must be specified as a relative path
, not an absolute path, and it is relative to the application base
directory.

[quoted text, click to view]

Henning Krause [MVP]
10/29/2004 7:43:59 AM
Hello,

Try to add the path via AppDomain.CurrentDomain.AppendPrivatePath().. that
should help.

Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/?page=products)


[quoted text, click to view]

Chris Lewis
10/29/2004 8:30:35 AM
Hi Henning,

I had already tried this - and I tried it again after your post, but to no
avail - I get the same error?

Chris


[quoted text, click to view]

Chris Lewis
10/29/2004 8:54:30 AM
Thanks a lot David, this worked for me!

Chris


[quoted text, click to view]

AddThis Social Bookmark Button