This project has moved. For the latest updates, please go here.

Not working with Unity, TypeLoadException

Jul 11, 2011 at 6:51 PM

I am trying to create a recorder in Unity.

I built the recent copy of your source code and added NAudio.dll to the reference list, and got this error:

Internal compiler error. See the console log for more information. output was: Unhandled Exception: System.TypeLoadException: Could not load type 'NAudio.Wave.WaveCallbackInfo' from assembly 'NAudio, Version=1.5.3.0, Culture=neutral, PublicKeyToken=null'.

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

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

Anyone knows how to resolve it? Very appreciate.

Coordinator
Jul 11, 2011 at 6:53 PM

you running this on mono? What OS is this for? NAudio plays audio by wrapping Windows APIs,

Jul 11, 2011 at 6:55 PM

Some more detailed lines of this error. May help. Thanks.

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

  at Mono.CSharp.TypeManager+Closure.Filter (System.Reflection.MemberInfo m, System.Object filter_criteria) [0x00000] in <filename unknown>:0

  at Mono.CSharp.MemberCache.FindMembers (MemberTypes mt, BindingFlags bf, System.String name, System.Reflection.MemberFilter filter, System.Object criteria) [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

 
Coordinator
Jul 11, 2011 at 6:57 PM

what OS is this for? NAudio is not likely to work on top of Mono.

Jul 11, 2011 at 6:58 PM

I did that in Mono. Do I have to do it in VS?

I am running it on a Windows 7 Enterprise x64.

Do you rely on some windows audio api libs?

What is required?

Very appreciate.

Jul 11, 2011 at 6:58 PM

Thanks. I am trying to reference in VS. Hope it works.

Jul 11, 2011 at 7:15 PM

What do you mean by 'NAudio is not likely to work on top of Mono.'?

If I create a wrapper class which does not derive from MonoBehaviour, then I could use NAudio, right?

Or I could never make it work with Unity?

Coordinator
Jul 11, 2011 at 7:18 PM

you would need to ask a mono/unity expert that. NAudio uses Windows APIs, so it can only run on Windows. I don't know if Mono is able to call those Windows APIs directly.