Hello,
I am new to Unity and c# and would be grateful for some help please.
I am using Windows 7, 64bit and Unity 4.1.04f Pro (trial version) with MonoDevelop 2.8.2. I want to use a managed 64bit 3rd party DLL (compiled in c# in .NET framework 4.0) in Unity. I’ve added the 3rd party DLL in the Assets folder and the DLL is clearly shown in References in MonoDevelop. I tried building for the target framework Mono/.NET 4.0 and 3.5 for any CPU platform but getting error "COMException at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (Int32 errorCode) [0x0000d] in Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:1031 "
(BTW, I managed to compile the 32bit version of the 3rd party DLL via [DllImport] but it crashes Unity. I don’t want to use the 32bit version, anyway.)
My code looks something like this:
using UnityEngine;
using 3rdParty;
using System.Runtime.InteropServices;
public class MyClass: MonoBehaviour {
void Start()
{
builder b = new builder(); //this is an object from the 3rd party DLL
b.MethodB(); // this is a method from the 3rd party DLL
}
}
Any idea, please? Thank you!