Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unmanaged C++ - need strong name to be referenced by C++/CLI dll with strong name?

I have a unmanaged C++ dll, which will be used by a managed C++/CLI wrapper .dll, which will eventually be used by a C# project.

C# project is strong-named, so is the wrapper .dll. I tried doing the same for the unmanaged dll, using /KEYFILE, but doesn't seem to work. And the wrapper is complaining:

.... is a strong-name signed assembly and embedding a manifest invalidates the signature

Do I need to strong-name the unmanaged C++ at all? If not, how do I resolve this issue?

like image 365
M W Avatar asked Jan 01 '26 01:01

M W


1 Answers

Finally got it all working, i.e. my C# app calls C++/CLI wrapper dll, which calls a class in native C++ dll!

To solve the problem:

mt.exe : general warning 810100b3: ... MyWrapper.dll is a strong-name signed assembly and embedding a manifest invalidates the signature. You will need to re-sign this file to make it a valid assembly.

IMPORTANT: It turns out the strong name in referenced class was not the issue.

It turns out there is something wrong with how VS sign the wrapper dll in this case. See link: http://blogs.msdn.com/b/vcblog/archive/2011/03/11/10140139.aspx

In short, to solve this, in your wrapper C++ class, add this as your Post Build command to re-sign:

sn.exe -R $(SolutionDir)$(Configuration)\MyWrapper.dll MyKeyFile.snk
like image 102
M W Avatar answered Jan 02 '26 15:01

M W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!