Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2004

Tip: Looking for answers? Try searching our database.

Assembly.LoadFrom problems called from WindowsService

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Lewis - 28 Oct 2004 22:10 GMT
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 - 28 Oct 2004 22:43 GMT
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.

> Hi,
>
[quoted text clipped - 18 lines]
>
> Chris Lewis
Chris Lewis - 29 Oct 2004 08:54 GMT
Thanks a lot David, this worked for me!

Chris

> 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?
[quoted text clipped - 27 lines]
> >
> > Chris Lewis
Henning Krause [MVP] - 29 Oct 2004 06:43 GMT
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)

> Hi,
>
[quoted text clipped - 15 lines]
>
> Chris Lewis
Chris Lewis - 29 Oct 2004 08:30 GMT
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

> Hello,
>
[quoted text clipped - 30 lines]
> >
> > Chris Lewis
David Levine - 29 Oct 2004 09:24 GMT
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.

> Hello,
>
[quoted text clipped - 32 lines]
>>
>> Chris Lewis

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.