0

I've got the following problem:

I have native C-Code as .api which needs to be extended by some function definitions to adapt it to our functionality. I can adapt it with C code compile it in a VS-Solution, works!

Now I want to call C# code from above mentioned C-Code. Thus I did:

[native C with extensions] --> [manged C++] --> [C#]

That works also.

Question: How can I reduce the number of assemblies?

What I found up to now:

  • Compile native C with option as CLR, didn't work because native code crashes.
  • Merge managed C++ and C# with ILMerge (as post-build action)

Reason: For security reasons we want to encrypt as many parts as possible. Thus best would be one .exe.

WorldSEnder
  • 4,875
  • 2
  • 28
  • 64
BlackTuareg
  • 160
  • 1
  • 11
  • [Mixed assemblies](https://msdn.microsoft.com/en-us/library/x0w2664k.aspx), this works for `C++` only. – Sinatr Jul 09 '15 at 14:00
  • how exactly this protecting you? – Svisstack Jul 09 '15 at 14:07
  • We can encrypt assemblies by a 3rd party tool, but it's very costy concerning file size and startup time. So the goal is to have as few assemblies to encrypt as possible ... which is one :-) – BlackTuareg Jul 09 '15 at 14:30

1 Answers1

0

Unfortunately you can't pack your native assembly with your CLR assembly. However, you can:

  • Merge all pure CLR assemblies into a single one using ILMerge;
  • Statically link all native assemblies (C, C++ and Managed C++) into a single DLL.

Thus you have only two files, one with the native code, one with the pure managed code. You can probably embed the native assembly into the managed one using embedded resources (see this msdn article or this stackoverflow question).

Community
  • 1
  • 1
slaphappy
  • 6,894
  • 3
  • 34
  • 59