Please see bottom for latest update.
I've looked elsewhere on the web and there doesn't seem to be a great deal of information regarding the use of PDFSharp in Unity.
PDFSharp looked like a good, simple solution to get my app to create pdf files, so I downloaded the library into my project's assets folder to get started.
This seemed to work at first, as the desired syntax was now available in my scripts in MonoDevelop. When I tried the run the app, however, it failed to compile and displayed the following error:
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
Being relatively new to Unity and completely new to any form of library extensions/file creation, I'm not sure what to do to resolve this. There's an awful lot of files in the PDFSharp folder to go through manually trying to find the root of the problem.
Does anyone have experience using PDFSharp with Unity, has encountered a similar problem and could help me solve it? I would be very grateful for any help.
Using the latest version of Unity with MonoDevelop and PDFSharp 1.31.
Using PDFSharp 1.32 threw up rather a few more errors: http://pastebin.com/PLUdZRbp
One link I looked at, but couldn't make much sense of: http://forum.pdfsharp.net/viewtopic.php?f=4&t=1206
Update: It turns out that I'd downloaded the source code instead of the assembly, so I downloaded that instead. The result was a lot better, but now it's throwing a TypeLoadException:
TypeLoadException: Could not load type 'PdfSharp.Charting.Renderers.RendererParameters' from assembly 'PdfSharp.Charting-WPF, Version=1.32.2608.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb'.
UnityEditor.DockArea:OnGUI()
It also appears that where I've used the line PdfDocument pdf = new PdfDocument(); in my script, it's throwing this error:
Assets/Scripts/Exporter.cs(18,17): error CS0433: The imported type `PdfSharp.Pdf.PdfDocument' is defined multiple times
Note: The TypeLoadException error, when the project is played with any scripts which use that library removed, actually causes Unity to crash to desktop.
Related
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
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
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.
I'm getting this error: compile time error when running i have searched on unity forum they are saying its for the System.Web.dll file issue, i have cleared that, also reimported assets but its still not working.
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
the answers i got from unity are :
http://answers.unity3d.com/questions/636739/reflectiontypeloadexception.html
http://answers.unity3d.com/questions/614268/added-custom-dll-internal-compiler-error.html
and none of them helped me.
The problem is caused by the Unity.PackageManager.dll in your project. Delete that and it will be gone.
You've also got a folder under Editor that contains a bunch of editor scripts for Standard Assets, but you don't have Standard Assets Installed, so you're going to get a bunch of compiler errors from that. Delete the Editor folder or install Standard Assets and it will work.
I'm not sure where you got the tutorial files, but nothing in this project seems to work correctly. All the scenes are empty. I would advise you go find a different tutorial.
Problems like this could be related to "Target Framework" setting in the DLL's compilation options. Which should be considered for already compiled system DLL's too.
So in your case, I think you might be using the wrong DLL version. If you need to import extra system DLL's, make sure you get them from Unity installation folder:
C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0
Beware that there might be multiple DLL's with the same name in other subfolders like MonoBleedingEdge. Make sure you use the folder above.
In case you build a DLL on your own, "Target Framework" setting should be set to a proper one. You may figure out the correct setting by trying.
I was getting this error when referencing a dll I had compiled with platform target set to Any CPU. Fixed by changing it to x86.
I fixed this error, when change Target framework to .Net Framework 3.5, and set the Copy Local to false of UnityEngine's references.
And after dragging the dll, the error is gone.
Hope this will help.
Wow I got a version of this
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. nonsense ... after couple hours of crying/raging, reimporting assets, deleting Library/Temp folders, changing platforms, reimporting plugins i finally got past it. Honestly I don't know exactly what fixed it .. ugh that was annoying.
I'm working on a Unity3d project that involves Databases,
I wanted the other developer to work on the server's and produce a DLL for me to use in Unity
I tried to work directly in Unity with SqlServerCe but it always stated that it's missing libs
So I managed to load the Backend's DLL successfully in Unity3D (Using v3.5 .Net Client Profile, in both the VS and Unity's Mono Develop)
It initializes the SQL components successfully (reader ... etc)
But when I execute the reader the DLL returns this exception as a string (I handled that when an exception occurs it's returned as a string)
The Exception:
System.InvalidProgramException: Missing or incorrect header for method CompileQueryPlan
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand (CommandBehavior behavior, System.String method, ResultSetOptions options) [0x00000] in <filename unknown>:0
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader (CommandBehavior behavior) [0x00000] in <filename unknown>:0
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Data.SqlServerCe.SqlCeCommand:ExecuteReader ()
at AbuEl3orrefDatabaseBackend.DBHandler.PrepareAllQuestions () [0x00000] in <filename unknown>:0
Well I finally found the solution,
I was on Web Platform, as it doesn't support SQL Server Compact, so I switched to Desktop Platform from the Build Settings.
I am creating a small GUI in WinForms and am currently working on implementing a syntax highlighter. I found a library that runs great in windows and provides a dll for usage. However, the library seems to always crash in Linux. Here is the error I'm getting:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at FastColoredTextBoxNS.FastColoredTextBox..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) FastColoredTextBoxNS.FastColoredTextBox:.ctor ()
at FDE.FGUI..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) FDE.FGUI:.ctor ()
at FDE.FGUI.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at FastColoredTextBoxNS.FastColoredTextBox..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) FastColoredTextBoxNS.FastColoredTextBox:.ctor ()
at FDE.FGUI..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) FDE.FGUI:.ctor ()
at FDE.FGUI.Main () [0x00000] in <filename unknown>:0
From the error message, it seems that Mono isn't seeing the dll given the <filename unknown> error during the constructor. Admittedly, The library I'm using (FastColoredTextBox) does not pass MoMA as it has a fair amount of P/Invokes. However, some people seemed to say they were able to get it running by avoiding the conflicting methods.
Here's the clincher, though. I decided to try to run the GUI through WINE and completely bypass Mono. Since it ran fine it Windows, I thought this would fix the error. However, the exact same error message pops up in Wine. I even have a shared folder between Windows and my Ubuntu live machine. The same exact executable will run on perfect Windows, but crash with this error in Linux. At this point, after hours of researching, I'm stumped.
Is there a certain way a dll has to be loaded in Mono or does the error lie in Mono/Wine incompatibilities with WinForms?
I looked at the source to the library. Assuming I've found the right library, it's calling the Win32 API, which isn't going to work on stock Mono.
Running under Wine should work better, but Wine is only partially implementing the Win32 API.
You may need to find a cross-platform replacement.
I am a unity developer trying my hands on opencv for the first time. My initial goal is to run the camera and detect blobs via opencv in unity3d. I am new to OpenCV and am trying to integrate it in Unity3D (on Windows 8 with Unity 4.3.2 and on a mac with Unity 4.2.1f). I followed this thread. But I am getting the following error as soon as I add a new C# script. And the moment I delete this script, the error goes (this script is Unity generated C# script).
Internal compiler error. See the console log for more information. output was:
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
I couldn't find much about Unity and OpenCV integration. It would be great if you could help me out with this error and point me to a recent tutorial to learn more.
Thanks in advance!
We recently had to deal with the same problem, I'll post some generic information that would solve your problem and help other people.
OpenCV library and your OpenCV project must be compiled as static libraries (see OpenCV as a static library).
OpenCV library and your OpenCV project must be compiled for both 32bit and 64bit architectures.
The 32bit version will be used inside the editor (since the Unity3D editor supports 32bit architectures only), the 64 bit version for production.
The compiled OpenCV project must be copied inside the Asset > Plugins folder, the OpenCV library must be copied inside the Assets folder.
To use your OpenCV project inside a C# script, follow this code example:
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
public class PluginImport : MonoBehaviour {
//Lets make our calls from the Plugin
[DllImport ("OpenCVProject")]
private static extern int openCVFunction();
void Start () {
openCVFunction();
}
}
pay attention to the using directives!
Other sources of information:
Unity Manual:Plugins