C# DLL compiler error

Hi.

I imported C# DLL to Assets/
And created new C# code:

using UnityEngine;
using System.Collections;

using DllName.SomeNamespace;

public class TestTest : MonoBehaviour {

	void Start () {
		TestObject testObject = new TestObject();
	}
	
	void Update () {
	
	}
}

MonoDevelop’s editor shows no errors.
The error massage i get from Unity is:

Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.TypeLoadException: Could not load type ‘DllName.SomeNamespace.TestObject’ from assembly ‘DllName, Version=3.9.0.0, Culture=neutral, PublicKeyToken=null’.

at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)

at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in :0

at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] in :0

at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] in :0

at Mono.CSharp.MemberCache…ctor (IMemberContainer container) [0x00000] in :0

at Mono.CSharp.TypeHandle…ctor (System.Type type) [0x00000] in :0

at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] in :0

at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] in :0

at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean used_cache) [0x00000] in :0

at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in :0

at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in :0

at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in :0

at Mono.CSharp.Expression.MemberLookupFinal (Mono.CSharp.ResolveContext ec, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in :0

at Mono.CSharp.New.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in :0

at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in :0

at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in :0

at Mono.CSharp.Assign.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in :0

at Mono.CSharp.SimpleAssign.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in :0

at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in :0

at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in :0

at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext ec) [0x00000] in :0

at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in :0

at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in :0

at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in :0

Any ideas…? :expressionless:

Where is DLLName.SomeNamespace?
It should be within Assets/Plugins, and are you sure the full namespace includes the DLLName?
Does DLLName contain any other dependency DLLs or references that are not standard within Unity?

Edit: Also try to load the DLL independently and reflect on individual types, it could be a specific non-CLI compliant type or it could be the whole assembly is funky.

I read somewhere that only native-code’s DLL such as C\C++ Objective C should be placed in Assets/Plugins. This one is compiled from C#. Is it mistake?

C# plugins work in that folder (It’s where I place mine). They also sometimes work when placed in Assets/ but I find that unreliable (sometimes they just are not found).

Hi.
I added all references DLLs to the project, and moved them to Assets/Plugins.
now, i got this error:
InvalidProgramException: Invalid IL code in DllName.SomeNamespace.TestObject:.ctor (): IL_0015: call 0x0600027f

Well what does TestObject’s Constructor look like?
Is this compiled using /unsafe, does it use pointers?
Was it compiled in .NET 4.0? What version of .NET/Mono was it compiled in?
What is TestObject supposed to do(maybe it could hint at unsupported features)?