简体   繁体   中英

Programmatically add a strong named assembly to the GAC

Is there anyway to programmatically add a strong named assembly to the GAC using C# code ?

Thanks

This Microsoft Support article, How to install an assembly into the Global Assembly Cache in Visual C# , should explain all you need to know.

This is typically a task performed by the installer, so I'm not sure why you'd want to do it from within a .NET program (unless I've misunderstood your question). However, you can simply use the System.Diagnostics.Process class to run all the necessary programs as an installer might.

The Global Assembly Cache is configured through a COM-like interface( http://support.microsoft.com/default.aspx?scid=kb;en-us;317540 ).

For all questions about the GAC, Jungfen Zhang's blog is the source of choice. http://blogs.msdn.com/junfeng/articles/229648.aspx
http://blogs.msdn.com/junfeng/articles/229649.aspx

For more information, search for "managed GAC API".

Gacutil.exe is only for development purposes and should not be used to install production assemblies into the global assembly cache.

[Microsoft Installer] is the recommended and most common way to add assemblies to the global assembly cache. The installer provides reference counting of assemblies in the global assembly cache, plus other benefits.

只需调用gacutil命令

gacutil /i mydll.dll

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