hkaraoglu
hkaraoglu

Reputation: 1345

How can I use .NET framework 4.5 in Unity 5

I'm working with unity3D 5. And I wanna import external my KinectDB.dll (includes my sql server db functions with entityframework. And it was complied with .NET 4.5 framework) class library to unity. But unity console gives me an error like below. I searched for this problem many hours. But I can't reach to complete solution. How can I solve this? What are your advices? Thanks in advance.

Hint : I created an example project with .NET 3.5 framework. And I import it to unity. Unity doesnt give me an error in this case.

  Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

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

  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

Missing method .ctor in assembly -------\Assets\KinectDB.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in KinectDB
Can't find custom attr constructor image: Assets\KinectDB.dll mtoken: 0x0a00000e

Upvotes: 2

Views: 6609

Answers (2)

Lex Li
Lex Li

Reputation: 63143

You can only wait till Unity updates its bundled Mono to 4.x. It is already on their roadmap. With Microsoft licenses Mono runtime from LGPL to MIT and Unity joined .NET Foundation, it is likely that such a platform upgrade might come sooner.

http://unity3d.com/unity/roadmap

Upvotes: 1

TomTom
TomTom

Reputation: 62093

Yeah. It all starts with reading the documentation - and realizing that Unity uses a quite outdated version of .NET. You CAN NOT use 4.5 libraries in Unity. What you CAN do is run them in a separate program and communicate with this program via network etc. - but that is a LOT of work.

Once in the future Unity will upgrade. But they have not yet.

Upvotes: 0

Related Questions