- Home /
Using C++/CLR classes in C# plugins - GetExceptionPointers not implemented exception
Hi, I'm currently working on a project that relies heavily on hand tracking and I'm trying to integrate a third party C++ library into Unity. My approach is the following:
- Wrap native library code in a C++/CLR class and export is as .dll 
- Wrap the wrapper (sigh) in a C# class and export as .dll 
- Use the C# .dll as managed plugin in Unity 
Inside the C# class, I construct the C++/CLR class and then use it in a pointer-to-implementation fashion. I tested my solution on a simple C# console app and it works just fine. However, in Unity I encounter a problem. When constructing the wrapper class I get the following exception:
  NotImplementedException: The method or operation is not implemented. System.Runtime.InteropServices.Marshal.GetExceptionPointers () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:413) .___CxxCallUnwindDtor (System.MonoFNPtrFakeClass pDtor, System.Void* pThis) (at :0) ..cctor () (at :0) Rethrow as TypeInitializationException: The type initializer for '' threw an exception. HandTracking.HandTracker..ctor () (at <46a0c6cbfc0b4b4e97e46ca2a3c2eed8>:0) TestScript.Start () (at Assets/Scripts/TestScript.cs:11)
My Unity script looks like this:
 public class TestScript : MonoBehaviour {    
     HandTracking.HandTracker handTracker;
     void Start ()
     {
         handTracker = new HandTracking.HandTracker();
     }        
 
     void Update ()
     {
         handTracker.Update();
     }
 }
The line that throws that exception is in the Start() method. HandTracking.HandTracker class looks like this:
     public class HandTracker
     {
         HandTrackingWrapper.HandTracker impl;
         public HandTracker()
         {
             impl = new HandTrackingWrapper.HandTracker();
         }
 
         public void Update()
         {
             impl.Update();
         }               
     }
HandTrackingWrapper.HandTracker is the CLR class that I mentioned earlier and it seems that its constructor is causing all the hassle. I have a couple of questions:
- Why does my approach work in a "normal" C# app setting, but not in Unity? 
- Is it possible to avoid the "wrapper of wrapper" stuff and just use the CLR library as a managed plugin (I had problems with that, as Unity recognizes the CLR .dll as native)? 
- Most importantly - how to fix my problem? 
EDIT: I took a peek at Mono code and indeed, System.Runtime.InteropServices.Marshal.GetExceptionPointers () is unimplemented. Is there any way to prevent it from being called?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                