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. Current directory issue to load a assembly thru reflection

Current directory issue to load a assembly thru reflection

Scheduled Pinned Locked Moved C#
helpdebuggingquestion
6 Posts 4 Posters 1 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.
  • S Offline
    S Offline
    shivapriyak
    wrote on last edited by
    #1

    Hi, I am trying to load a assembly thru reflection using: Assembly asm = domain.Load(AssemblyName) I understand that the assembly should also be in the currrent directory (DEBUG folder) in order to load it, though it is present in te location specified. I have tried setting a new location as my current directory before loading, using: Directory.SetCurrentDirectory(...) But still it is not loading the assembly though the dll is there in that path and NOT present in the DEBUG folder. Can anyone help me with this? Thanks, Priya.

    N S J 3 Replies Last reply
    0
    • S shivapriyak

      Hi, I am trying to load a assembly thru reflection using: Assembly asm = domain.Load(AssemblyName) I understand that the assembly should also be in the currrent directory (DEBUG folder) in order to load it, though it is present in te location specified. I have tried setting a new location as my current directory before loading, using: Directory.SetCurrentDirectory(...) But still it is not loading the assembly though the dll is there in that path and NOT present in the DEBUG folder. Can anyone help me with this? Thanks, Priya.

      N Offline
      N Offline
      natsuyaki
      wrote on last edited by
      #2

      I think Assembly auto searches assemblies in GAC and application folder. You'd better pass a absolute or relative path to it, rather than setting current directory... ;P

      S 1 Reply Last reply
      0
      • S shivapriyak

        Hi, I am trying to load a assembly thru reflection using: Assembly asm = domain.Load(AssemblyName) I understand that the assembly should also be in the currrent directory (DEBUG folder) in order to load it, though it is present in te location specified. I have tried setting a new location as my current directory before loading, using: Directory.SetCurrentDirectory(...) But still it is not loading the assembly though the dll is there in that path and NOT present in the DEBUG folder. Can anyone help me with this? Thanks, Priya.

        S Offline
        S Offline
        Spunky Coder
        wrote on last edited by
        #3

        i guess u r trying to load an assembly by specifying a path to a dll if so try the following... System.Reflection.Assembly asmb = System.Reflection.Assembly.LoadFrom("dll path");

        .....

        S 1 Reply Last reply
        0
        • S Spunky Coder

          i guess u r trying to load an assembly by specifying a path to a dll if so try the following... System.Reflection.Assembly asmb = System.Reflection.Assembly.LoadFrom("dll path");

          .....

          S Offline
          S Offline
          shivapriyak
          wrote on last edited by
          #4

          Thanks for the reply. But this would load into AppDomain, I want to load into a Temporary domain which i created: AppDomain domain = AppDomain.CreateDomain("TempDomain"); Thats why i am using: domain.Load(Assemblyname)

          1 Reply Last reply
          0
          • N natsuyaki

            I think Assembly auto searches assemblies in GAC and application folder. You'd better pass a absolute or relative path to it, rather than setting current directory... ;P

            S Offline
            S Offline
            shivapriyak
            wrote on last edited by
            #5

            Thanks for the reply but I didn't understand where I should pass the absolute path. The statement: Assembly asm = domain.Load(asmName); does not take a path. I am trying to load into a temporary domain and not the current App Domain.

            1 Reply Last reply
            0
            • S shivapriyak

              Hi, I am trying to load a assembly thru reflection using: Assembly asm = domain.Load(AssemblyName) I understand that the assembly should also be in the currrent directory (DEBUG folder) in order to load it, though it is present in te location specified. I have tried setting a new location as my current directory before loading, using: Directory.SetCurrentDirectory(...) But still it is not loading the assembly though the dll is there in that path and NOT present in the DEBUG folder. Can anyone help me with this? Thanks, Priya.

              J Offline
              J Offline
              jpsstavares
              wrote on last edited by
              #6

              I'm having the same problem here. Directory.setCurrentDirectory won't work because that method is, I think, for FileBrowsers. I've tried to create the appDomain with appBasePath and appRelativeSearchPath but it still doesn't work (I get a FileNotFoundException). The Assembly is definitely in the path provided. Did you solved this? TIA Jose Tavares

              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