I’m using Unity 2016.4.16f1, UWP platform with IL2CPP scripting backend for hololens2 development.
I had to use 3rd party external UWP library as a reference to the unity application. The IL2CPP build is working fine without any compilation errors. But while running the application, I get this below exception :
'ModelManagementPINVOKE.SWIGExceptionHelper threw an exception. —> System.NotSupportedException: To marshal a managed method, please add an attribute named ‘MonoPInvokeCallback’ to the method definition.
Since I use the external library, I do not have the source code. Also, the MonoPInvokeCallback is not a UWP attribute, but Mono/Unity attribute. Any suggestions on how to proceed further?
Yes, we had contacted and they have mentioned that as MonoPInvokeCallback is not a UWP attribute (meaning not from UniversalWindows assembly), but from Unity/Mono.
So the external library should have a dependency on Unity? What exactly are the steps in order to make it work for IL2CPP compatible?
The external library does not need a dependency on any Unity code. The MonoPInvokeCallback attribute is looked up by name. So the vendor just needs to define an attribute with that name in their code, and then use it. They can define it like this:
class MonoPInvokeCallbackAttribute : System.Attribute
{
}