Referenced assembly from dynamically generated assembly.
-
Hi, I am using CSharpCodeProvider for the first time (.NET 1.1 & VS2003). My application has been used without problems for a few weeks. Now I started using an external assembly (PortController.NET) from the generated assembly. I can access the generated assembly (create objects and call methods) but when it reaches the poing where it uses PortController.NET (creating new object) I get the exception: File or assembly name PortController.NET, or one of its dependencies, was not found. But it works when executed through the debugger!? My code looks like this:
ICodeCompiler comp = (new CSharpCodeProvider().CreateCompiler()); CompilerParameters cp = new CompilerParameters(); cp.ReferencedAssemblies.Add("system.dll"); cp.ReferencedAssemblies.Add(@"C:\Program Files\PortController.NET\PortController.NET.dll"); cp.GenerateExecutable = false; cp.GenerateInMemory = true; CompilerResults cr = comp.CompileAssemblyFromFile(cp, filepath);
In VS2003 PortController.NET is listed in the .NET list (for adding references) so I guess it's in the GAC. Any suggestions? Thanks, Jan -
Hi, I am using CSharpCodeProvider for the first time (.NET 1.1 & VS2003). My application has been used without problems for a few weeks. Now I started using an external assembly (PortController.NET) from the generated assembly. I can access the generated assembly (create objects and call methods) but when it reaches the poing where it uses PortController.NET (creating new object) I get the exception: File or assembly name PortController.NET, or one of its dependencies, was not found. But it works when executed through the debugger!? My code looks like this:
ICodeCompiler comp = (new CSharpCodeProvider().CreateCompiler()); CompilerParameters cp = new CompilerParameters(); cp.ReferencedAssemblies.Add("system.dll"); cp.ReferencedAssemblies.Add(@"C:\Program Files\PortController.NET\PortController.NET.dll"); cp.GenerateExecutable = false; cp.GenerateInMemory = true; CompilerResults cr = comp.CompileAssemblyFromFile(cp, filepath);
In VS2003 PortController.NET is listed in the .NET list (for adding references) so I guess it's in the GAC. Any suggestions? Thanks, JanHi, The problem is probably with Fusion ( the system responsible for loading assemblies ). You cannot load an assembly that lives outside the .exe directory structure. So either make sure the PortController.NET.dll assembly is in the GAC, or just put it in the same directory as your .exe. Either way, remove the path from the call to
ReferencedAssemblies.Add
. If this doesn't work you will have to use Fuslogvw.exe to check the fusion logs. I seem to remember you have to clear your temporary internet files first. You used to be able to view the GAC using Explorer ( at C:\Windows\assembly ), but I just checked my system and it seems to have disappeared :wtf: ---------------------------- Be excellent to each other :) -
Hi, The problem is probably with Fusion ( the system responsible for loading assemblies ). You cannot load an assembly that lives outside the .exe directory structure. So either make sure the PortController.NET.dll assembly is in the GAC, or just put it in the same directory as your .exe. Either way, remove the path from the call to
ReferencedAssemblies.Add
. If this doesn't work you will have to use Fuslogvw.exe to check the fusion logs. I seem to remember you have to clear your temporary internet files first. You used to be able to view the GAC using Explorer ( at C:\Windows\assembly ), but I just checked my system and it seems to have disappeared :wtf: ---------------------------- Be excellent to each other :)