Reputation: 2691
I have C++ dll. Than I wrote .NET Wrapper to this C++ dll, and I can attach .NET wrapper to my project and use C++ library in it. But now I have two files: c++.dll and wrapper.dll. The problem is with c++.dll, someone can replace c++.dll and inject its code to my application through wrapper.dll. How can I embed c++.dll to .net wrapper to get one .net wrapper dll?
Thanks
Upvotes: 1
Views: 1090
Reputation: 1
You could try merging them (with ILmerge, for instance), though I'm not sure how useful that would be. Then again, if you merge as many files as possible into one single file, that could help your security at least a bit. This might help: http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx
Hopefully that helps.
Upvotes: 0
Reputation: 31642
Simple: Don't.
You could bundle the C++ DLL into the .NET Assembly as a resource - but then these malicious users could just use ILDASM or Reflector or whatever to pull resources out of your .NET assembly - or decompile your .NET wrapper and recompile it with whatever code they want.
Bottom line is, you're really barking up a tree you can't climb (you can do things to dissuade people, but you're not going to stop them from messing with your app if they really want to) - and somehow merging your DLLs into one file really isn't going to give you any meaningful benefit.
Upvotes: 3