Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Referenced assembly from dynamically generated assembly.

Referenced assembly from dynamically generated assembly.

Scheduled Pinned Locked Moved C#
csharpdotnetdebuggingquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    janman
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • J janman

      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

      N Offline
      N Offline
      Nicholas Butler
      wrote on last edited by
      #2

      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 :)

      J 1 Reply Last reply
      0
      • N Nicholas Butler

        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 :)

        J Offline
        J Offline
        janman
        wrote on last edited by
        #3

        Thanks for a very fine and serious answer. 5 from here. I can't wait to get back to work monday. Cheers

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups