P
P
patch12015-09-10 04:49:01
Mono
patch1, 2015-09-10 04:49:01

How to fix an error when connecting a C# DLL library to Unity3d?

Good morning everyone. Actually here is an error when accessing an external method. The DLL is written in C#. Full log file. link .

-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll

Internal compiler error at Assets/ApplicationMain.cs(6,14):: exception caught while emitting MethodBuilder [ApplicationMain::Start]

The class Microsoft.Win32.RegistryKey could not be loaded, used in mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

-----CompilerOutput:-stderr----------



Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Win32.RegistryKey' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.



  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)



  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 



  at System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) [0x00000] in <filename unknown>:0 



  at System.Reflection.MonoMethod.get_Attributes () [0x00000] in <filename unknown>:0 



  at System.Reflection.MethodBase.get_IsVirtual () [0x00000] in <filename unknown>:0 



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



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



  at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0 



  at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0 



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



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



  at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] in <filename unknown>: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 <filename unknown>: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 <filename unknown>: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 <filename unknown>: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 <filename unknown>:0 



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



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



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



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



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



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



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



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



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



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



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

-----EndCompilerOutput---------------

- Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll

Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Win32.RegistryKey' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)

  at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0 

  at System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) [0x00000] in <filename unknown>:0 

  at System.Reflection.MonoMethod.get_Attributes () [0x00000] in <filename unknown>:0 

  at System.Reflection.MethodBase.get_IsVirtual () [0x00000] in <filename unknown>:0 

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

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

  at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0 

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

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

  at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] in <filename unknown>: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 <filename unknown>: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 <filename unknown>: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 <filename unknown>: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 <filename unknown>:0 

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

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

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

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

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

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

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

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

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

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

  at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0 
 
(Filename:  Line: 0)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
patch1, 2015-09-10
@patch1

Everything seems to be fixed. The error was not in the DLL build, not in the .Net framework version, but in the fact that the target platform was in the Web Player settings. Although the error crashes in the editor itself without launching or builds))) I would like to add more. if a library works for you in the DLL editor, but after exporting it to the desired OS or platform, it does not work. then for example, try changing the OS for export. Under Windows, I changed x86 to x86_64. and what worked in the editor worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question