- Home /
Internal Compiler Error, caused by System.Windows.Forms.dll
I have two projects, on the first one I'm working for a long time now and at one point I integrated the System.Windows.Forms.dll in the folder Plugins to be able to have a proper file dialog. The second project was just created now with the newest release of Unity (and Mono) the second project was created to isolate one feature out of the first project and so to make a unity-package out of it.
The first project uses the DLL with no problems at all and it is also using the newest version of Unity by now, but it started using the DLL with a previous version and was always updated.
I copied the DLL so it is exactly the same as in the first one in the second one, I even copied the folder as a test, but nothing works at all. Once I try to use the forms library the Internal Compiler error occurs. If no script tries to use it everything is fine and even writing "using System.Windows.Forms;" does not make the error occur first when it says: "openDialog = new OpenFileDialog();" the Internal Error shows reading:
Internal compiler error. See the console log for more information. output was: Unhandled Exception: System.TypeLoadException: Could not load type 'System.ComponentModel.CancelEventHandler' from assembly 'System, 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 unknown>:0 at System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) [0x00000] in unknown>:0 at System.Reflection.MonoMethod.get_Attributes () [0x00000] in :0 at System.Reflection.MethodBase.get_IsVirtual () [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
the following is the script trying to use the DLL.
using System.Collections;
using System.Windows.Forms;
public class LoadManager
{
private static OpenFileDialog openDialog;
public LoadManager ()
{
//
}
public static string[] OpenFileDialog ()
{
openDialog = new OpenFileDialog();
openDialog.InitialDirectory = UnityEngine.Application.dataPath;
openDialog.Filter = "music files (*.mp3;*.wav)|*.MP3;*.WAV|All files (*.*)|*.*";
openDialog.Title = "Select some music you want to listen to during this Game session.";
openDialog.Multiselect = true;
string[] result = null;
if (openDialog.ShowDialog() == DialogResult.OK)
{
result = openDialog.FileNames;
}
if (openDialog.FileName == string.Empty)
{
result = null;
}
openDialog = null;
return result;
}
}
I'm completely helpless with this and I'm running both projects on the same Laptop, with the same version of Unity... I have no clue at all and I would be very very thankful for any kind of help
Answer by _monoflow · Jul 02, 2014 at 01:21 PM
Change your settings: "Build Settings/Player Settings/Other settings/Api Compatibility Level" to .NET2.0 (not subset)