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 / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Assembly.LoadFrom failing in .NET 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John H - 07 Jul 2006 16:18 GMT
Hi,

We have an application that generates .NET assembly DLLs at runtime and
executes them. It normally generates the assembly DLL once per user
task and any time the same user task is done again it simply loads the
already existing DLL and executes it.

We are using the .NET Code DOM to compile the .NET DLLs and then using
reflection to call them.

This is working fine in .NET 1.1, however on a machine with .NET 2.0
installed we are getting different behaviour.

The code does the following:

           Call Assembly.LoadFrom() to determine if DLL is generated

           If (call Failed)

{

                       Generate DLL and save to hard disk

                       Get Assembly from
CompilerResults.CompiledAssembly

           }

           Execute method on generated Assembly DLL

When using .NET 2.0 the Assembly.LoadFrom() call fails correctly the
first time and then generates the DLL successfully. However, the
assignment of CompilerResults.CompiledAssembly fails even though the
DLL is now created. Any further calls to Assembly.LoadFrom() for the
same DLL in the same process also fail, they return the error "Failed
to load DLL or one of it's dependencies".

However, when I then stop and start the process the Assembly.LoadFrom()
calls work.

It seems that the fact that the first Assembly.LoadFrom() call failed
is cached in the current process and any subsequent calls to load the
same DLL automatically fail.

Is this a change in .NET 2.0?

Is there a way around this?

Thanks for any help you can give,

                                   John.
John H - 13 Jul 2006 15:40 GMT
Hi,
In case anyone is interested got an answer on

http://discuss.develop.com/archives/wa.exe?A1=ind0607a&L=advanced-dotnet
It's the second one from the top.

It appears to be due to a change/bug introduced into LoadFrom in .net
2.0

John

> Hi,
>
[quoted text clipped - 47 lines]
>
>                                     John.

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.