Simple way assuming class Foo:
- Create a C++/CLI project, call this FooWrapper.
- Make FooWrapper depend on the unmanaged dll (however you normally would).
- Create a managed class ManagedFoo which contains a single private instance field of type Foo*.
- provide public wrapping functions in ManagedFoo which forward on to the underlying instance field.
- Optionally (though recommended):
- convert parameters from .net idioms (strings and the like) to C++ idioms (std::string or char*)
- catch unmanaged exceptions and throw managed ones instead
Then you make your c# code depend on the FooWrapper project/dll and ensure that the unmanaged dll is properly deployed with it, how that is done depends on the unmanaged dll but in the same directory is normally sufficient.
If the functions do not rely on instances of the class then even simpler is P/Invoke