|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Assembly.LoadFrom failing in .NET 2.0We 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. 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 John H wrote: Show quote > 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. |
|||||||||||||||||||||||