Reputation: 187
I am actually converting a cpp program into a c# dll. In cpp I have used some header files which contains some structs that are required. I am creating a dll in C#. How do I link the header files in C#? Can I build it as a static cpp library and link it to dll?
regards, shiksha
Upvotes: 0
Views: 1072
Reputation: 1794
as @keugyeol said You can't include the C++ headers in a C# application, you can convert the c++ structures to C# ones, this site for the interoperability between C# and C++ look at their implementation of the structs, the following attribute is commonly used
[StructLayout(LayoutKind.Sequential)]
but it is easier to convert the native c++ code to managed c++ and include your files, the output dll can be used in c#, or can be converted to C# using applications such ILSpy [that reverse the .Net Assembly in C# or VB Code]
Upvotes: 1
Reputation: 2435
You cannot directly use the C++ header file in C# but you can convert the C++ structs to C# quite easily, I suppose, since I am not aware of your specific struct types.
Upvotes: 1