简体   繁体   中英

Add Reference to GAC Assembly copies Non GAC dependent assemblies recursively (c# Visual Studio 2008)

This is my application deplyoment: c:\\Program Files\\Product\\API.dll (Registered in Gac)
c:\\Program Files\\Product\\ApiImpl1.dll (Non Gac)
c:\\Program Files\\Product\\ApiImpl2.dll (Non Gac)
c:\\ConsoleApplication\\TestApi.exe

Api.dll is Facade for Application which implemented "c:\\Program Files\\Product\\" Api.Dll is registered in GAC and has Assembly Resolver to DLLs which is located in "c:\\Program Files\\Product\\" Api.dll reference both ApiImpl1.dll and ApiImpl2.dll.

The problem is when in ConsoleApplication I add reference to Api.dll Visual Studio copies recusively the ApiImpl1.dll and ApiImpl2.dll to the project destination. (Although CopyLocal=False) I add the reference by Browsing to "c:\\Program Files\\Product\\API.dll"

As far as I know, I have several solutions:
1) Register ApiImpl1.dll and ApiImpl2.dll in GAC (Not acceptable, I have the Assembly Resolver for this)
2) Add to ".Net Add Reference" Registry, "c:\\Program Files\\Product" (Doesn't solve it)
3) Add to ".Net Add Reference" Registry, "c:\\windows\\Assembly\\gac_msil\\Api.dll (Solve it, but it is a bad solution)
4) Manually Change the ConsoleApplication.csproj and Remove HintPath attribute of Api.dll Reference. (Not acceptable, Because I will have a lot of customers which will use this API)

You should always have GAC-dependent dlls in the GAC... if one needs to be there, so do the others.

The problem is that while Visual Studio knows where to find these dll files by the references, the application at runtime will not know where to look if the dll files aren't in the project directory (hence the copy).


EDIT
Is it necessary to put API.dll in the GAC if you have the Assembly Resolver? Perhaps if that dll were not in the GAC, Visual Studio wouldn't copy the other files over. I'm pretty sure it's that fact that a root DLL is in the GAC, but dependent DLLs are not.

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