SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x8013141A)

泄露秘密 提交于 2019-11-30 13:42:31
Sandy

This problem is related to Strong Name Validation. Open your AssemblyX in Ildasm.exe(C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin). Note its PublicKeyToken, lets say pkt123 for an example. Now open VS Command prompt in administrator mode and run the sn.exe command. Such as:

sn -Vr *,pkt123

Build your solution again and everything should be fine by now.

But if not and you receive same error now also, then you need to run a different version of sn.exe. To locate that, go to Visual Studio command prompt.

c:\Program Files(x86)>dir /s sn.exe

It may take 5-10 seconds and should give a list of sn.exe files. Go to the path and execute the sn.exe, required or belongs to you, as shown above. If not sure which one to execute, execute all the sn.exe. That should and must solve your problem. If not, let me know and let me carry forward the RnD again.

Since I'm not able to comment on the only answer to this I wanted to make sure that other users that came upon this answer as I did do not make the same mistakes other may have. According to the MSDN documentation for the strong naming utility, using the Vr(signature skipping) switch can cause malicious assemblies to load and should only be used in DEVELOPMENT not deployment.

http://msdn.microsoft.com/en-us/library/k5b5tt23(v=vs.80).aspx

if still not resolved you have to delete or set AllowStrongNameBypass (DWORD) to "1" in the key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

On 64-bit computers,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

and

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework

In my case the reason was that the native library was built to different folder then the rest of application.

user2190799

Open cmd.

Cd  "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin"   

Run:

sn –Vr **AssemblingX** name (without dll extension), **PublicKeyToken**

(the code)

Rebuild the solution. And it should be solved.

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