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. .NET (Core and Framework)
  4. Loading dll and resources from wrong folder

Loading dll and resources from wrong folder

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpquestionhelpworkspace
6 Posts 3 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.
  • M Offline
    M Offline
    marca292
    wrote on last edited by
    #1

    I have two C# .NET applications, AppA (located in folder A) and AppB (located in folder B). AppB is also using a lot of 3rd party dll:s and configuration files located in folder B. If I start AppB from folder B the application is working as expected. The problem is when I start appB from appA using Process.Start(), and Process.StartInfo.FileName is pointing to appB. AppB is now starting up, but it seems like it is trying to load resources from folder A instead of folder B. How can I solve this? appB shall always load resources and dll:s from folder B.

    A 1 Reply Last reply
    0
    • M marca292

      I have two C# .NET applications, AppA (located in folder A) and AppB (located in folder B). AppB is also using a lot of 3rd party dll:s and configuration files located in folder B. If I start AppB from folder B the application is working as expected. The problem is when I start appB from appA using Process.Start(), and Process.StartInfo.FileName is pointing to appB. AppB is now starting up, but it seems like it is trying to load resources from folder A instead of folder B. How can I solve this? appB shall always load resources and dll:s from folder B.

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      Have you tried setting the WorkingDirectory property of ProcessStartInfo?

      M 1 Reply Last reply
      0
      • A Alan N

        Have you tried setting the WorkingDirectory property of ProcessStartInfo?

        M Offline
        M Offline
        marca292
        wrote on last edited by
        #3

        Yes but is is still not working. From AppB i print System.IO.Directory.GetCurrentWorkingDirectory() and that path is alright. I Also print all loaded dll:s and when AppB is started through Process:Start, some dlls are not loaded

        A L 2 Replies Last reply
        0
        • M marca292

          Yes but is is still not working. From AppB i print System.IO.Directory.GetCurrentWorkingDirectory() and that path is alright. I Also print all loaded dll:s and when AppB is started through Process:Start, some dlls are not loaded

          A Offline
          A Offline
          Alan N
          wrote on last edited by
          #4

          OK I can't think of an obvious reason then. The only time I have seen the working directory set to that of the launching process is when ProcessStartInfo.UseShellExecute is true and Process.StartInfo.WorkingDirectory has not been set. You say some dlls are not loaded. What is the mechanism for loading these and why doesn't AppB crash if it can't find them?

          1 Reply Last reply
          0
          • M marca292

            Yes but is is still not working. From AppB i print System.IO.Directory.GetCurrentWorkingDirectory() and that path is alright. I Also print all loaded dll:s and when AppB is started through Process:Start, some dlls are not loaded

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Did you register the assemblies in the GAC? Sounds like it might be a registered component[^].

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

            M 1 Reply Last reply
            0
            • L Lost User

              Did you register the assemblies in the GAC? Sounds like it might be a registered component[^].

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

              M Offline
              M Offline
              marca292
              wrote on last edited by
              #6

              Thanks for all help. I got this working. The problem was timing problem in the 3rd party dll's. AppA is starting appB in a sandbox and adds overhead (=> timing problem). Because of this timeing problem a exception was throwed before all dll:s were loaded. (difficult to give a precise explanation of a few short lines here)

              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