need help on adding C++ project
-
I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.
-
I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.
you need to add reference to the project in your C# project. This is a guess.
-
I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.
If this is a Managed C++ project, then it produces an assembly that you can use like any other assembly in your C# project. If you want to call exported native functions, you need to learn about Platform Invoke. Read Consuming Unmanaged DLL Functions[^] and Marshaling Data with Platform Invoke[^]. If your project is a native VC++ project, your C# doesn't need a reference to it. Just make sure the compiled DLL is resolvable (i.e., either in the application's directory or in a directory within the PATH environment variable). Read about the
LoadLibrary
API in the Platform SDK for the exact steps that the Winodws executable loader uses to resolve executables.Microsoft MVP, Visual C# My Articles