I'm working on an application, which needs to base itself on a DLL, written in managed code (C#), in order to function. That DLL contains type definitions.

Therefore a convertor has been written, based on a *.json conversion file, which creates native C++ source code (the type definitions from the DLL get translated into native C++ types, and we have access to the source code of the DLL).

That auto-generated code is almost unreadable (last week I stumbled upon a line of 17980 characters), but there are also other issues.

I just wonder if there is no simpler way to handle such situation instead of auto-generating native code out of managed DLL and JSON, does anybody have an idea?

Thanks in advance

  • usually, auto-generated code is not meant for human consumption. For this reason, the authors of code generators don't even try to produce readable code as output of the generator. – Bart van Ingen Schenau Apr 4 '18 at 7:00
  • The problem isn't how to deal with a DLL. The problem is why a DLL? Wouldn't it be simpler to simply code an equivalent in C# and be done with it? – Neil Apr 4 '18 at 7:01
  • How do the C# and C++ code interact with each other? Do they directly call each other or do they exchange serialized data (for example, via files or a network connection)? – Bart van Ingen Schenau Apr 4 '18 at 7:03
  • I had success in the past using UnmanagedExports to make .Net DLL functionality available to native code (Delphi in my case, but that doesn't matter.) – Sebastian Redl Apr 4 '18 at 7:32
  • Have you considered COM? It’s purpose in life is to provide remote process calls like this. – RubberDuck Apr 4 '18 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.