Assembly generation failed — Referenced assembly 'Interop.Office' does not have a strong name

核能气质少年 提交于 2019-11-30 20:15:28
Matt

I spent a while trawling the internet for this, I believe that the answer you need may be here, for most 3rd party dll's.

"Adding Strong Name to Interop DLL"

The article describes three ways to add a strong name to a third party assembly. The commands are:
1. Adding a Strong Name via Key Pair

> SN -k MyKeyPair.snk
> ILDASM ASQLService.dll /out:ASQLService.il
> ILASM ASQLService.il /dll /resource=ASQLService.res /key=MyKeyPair.snk

2. Adding a Strong Name via a Certificate in a Certificate Store

> ILDASM ASQLService.dll /out:ASQLService.il  
> MAKECERT -ss MyCertificateStore -sk MyKeyContainer
> ILASM ASQLService.il /dll /resource=ASQLService.res /key=@MyKeyContainer

3. Adding a Strong Name via a Certificate in a Personal Information Exchange (.pfx) File

> MAKECERT -r -pe -sv MyCertificate.pvk MyCertificate.cer
> PVK2PFX -pvk MyCertificate.pvk -pi qwerty -spc MyCertificate.cer -pfx MyCertificate.pfx
> SN -p MyCertificate.pfx MyCertificate-publickey.snk
> ILASM ASQLService.il /dll /resource=ASQLService.res /key=MyCertificate-publickey.snk
> SN -R ASQLService.dll MyCertificate.pfx

Hope it helped

This comment should be an answer:

Actually, the "strong name" problem only STARTS if you decide to sign your assembly, since then it'll require all referenced dlls to be strong-name signed too

If you dont want to sign the assembly and wish to overcome this compilation error. Choose NOT to sign the assembly you are trying to build. Subsequently all the projects references wont require signing either.

You must have a .snk

Right click on your project -> Properties and go on Signing tab -> Check Sign the assembly -> choose new key

Hope it helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!