Search code examples
c#gac

Application.StartupPath called in a DLL in GAC, where it will resolved to?


I create an EXE ( let's call it a.exe), that calls a DLL (let's call it b.dll). Inside the b.dll there is this method

public string GetStartupPath()
{
  return Application.StartupPath;
}

I put the a.exe in C:\Program Files\My Company\My App folder. I install the b.dll in the GAC.

Now my question is, if I launch C:\Program Files\My Company\My App\a.exe, what will the method GetStartupPath() in b.dll returns?

I can do a simple sample to test, but I still decide to post this question here. Two reasons:

  1. I suspect that on different machines, different answer will return.
  2. For the benefit of other developers, canonical response based on the official documentation available on StackOverflow is very useful.

Solution

  • From the official docs:

    Gets the path for the executable file that started the application, not including the executable name.

    https://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath(v=vs.110).aspx

    So this means to me that it will give you the path where the exe lives.