简体   繁体   中英

Register and call .exe in GAC

Background:

I am working with a project where I have a 32-bit dll (lets call it MyDll.dll). I had to make MyDll.dll work for both 32 and 64 bit applications but since MyDll.dll is calling some other 32-bit dll I created an 32-bit .exe to work as a proxy (lets call it MyExe.exe). Now I can compile MyDll.dll as AnyCPU and it will start and send calls to MyExe.exe which is compiled as 32-bit. This is working when I put MyDll.dll and MyExe.exe in my project's Bin folder. (A more detailed description of the background can be found in this question )

My Problem:

The 32-bit DLL that I started with was registered in the GAC (GAC_32). I managed to register MyDll.dll compiled as AnyCPU in GAC (GAC_MSIL) and I can see that it is used correctly. However when I registered the 32-bit MyExe.exe in GAC (GAC_32) it is not used.

I am new to the GAC and I have two questions here:

  1. Can I make sure that MyDll.dll starts MyExe.exe when both these are located in the GAC? I start MyExe.exe like this:

     System.Diagnostics.Process.Start("MyExe.exe"); 
  2. Is this good practice or would it be better just to skip the GAC?

   Process.Start("MyExe.exe");

That asks the operating system to locate and start the MyExe.exe file. It will never look in the GAC for that file, it has no idea that this is a place to look for executable files. Nor could it possibly do that job, it doesn't know beans about the specific version you want.

The GAC is a managed code implementation detail, only the CLR knows about it. Chicken-and-egg, the CLR doesn't start until after the EXE starts running.

Which is the basic reason why there is no point in putting EXEs in the GAC. They belong in C:\\Program Files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM