Maybe you're using the wrong tool for the job?

Could be easier to create a wrapper class with Managed C++ which you then can use from C#.