Hi,
as i understand, basically your problem statement is:
There is a project in Unmanaged C++. You wan to call the functions in this Project in your C# application.
Here are the steps:
It is common practice to write complex or time consuming algorithmic code in C++, to leverage the speed and efficiency it offers.
Then export functions from C++ code which the module will reveal to other modules.
Then build this module as a .dll .
Then add the reference of this .dll to the C# or VB application.
Consume the functionality exposed by C++ .dll by calling the functions exposed by the .dll.
Trying to cover every step in detail will consume a lot of time. You will have to google for more details on any step.
Now there are different methods of exporting functions from a VC++ dll.
1). Number of files do not matter. Its better to build your C++ project as dll .
here is a simple walkthrough for creating VC++dll[
^].
Kindly google more on these lines. Export only the functions that you will consume from C# application. You can export functions from same file or from separate files. You can export functions only from 1 file while other files will not get disturbed.
2). All the .lib, .in, .def,.asm, and third party dlls will become a dependency for the new VC++ dll you will build. Try to understand what a .lib file and .def file are. The C# application need not bother about these. But to work correctly, the vc++ dll will need these other binaries in a defined location. Google more about how to manage dependencies of the dll.
3). Putting the dependencies in a separate module can be done . I think this is more of a design decision which only you can make since you know how large or complex your project is.
4). I do not know the scale of your project. If you are bothered about latency in calling the C++ dll, then better worry about these optimizations when you have the code working.
here are a few useful links:
How to Marshal a C++ Class[
^]
HowTo: Export C++ classes from a DLL[
^]
Exposing native to managed - C++/CLI vs. P/Invoke[
^]
writing-a-dll-in-c-c-for-net-interoperability[
^]
I just tried to give you pointers. A detailed answer would be very lengthy.
hope it helps !!