Internal Compiler Error

I am getting internal compiler error when i try to debug my unity scripts on Monodevelop-unity. (I could have been able to debug previously).
My project contains both c# script and java scripts. I am using NGUI, prime31 plugins.

I am totally stucked, i searched previous posts but i could not resolve the problem.

Regards

I’ve been having internal compiler errors in my project also, and there are a couple things I’ve found that could help.

First, there is a technique which works well for narrowing-down where the internal compiler error happens.

First the thought process:

A) I noticed that compiler errors showing up in Visual Studio, when I attempted to build the project there (which failed because Unity hadn’t built the DLL file, btw), were not showing up in the Unity console/error log.

B) This made me realize that the internal compiler error must be happening at some specific line in some specific file, and that once it hit that line, it stopped compiling the rest of the files. (and thus it never noticed the normal code issues (e.g. “int i = 0 / 0;”) that Visual Studio picked up)

C) I looked into the Unity Editor logs, and noticed that the files were all being sent to the compiler in alphabetical order–in other words, in basically the same order you see them in the Project view. (the one difference being how they handle capital letters–Unity and Visual Studio consider ‘a’ to be before ‘B’, whereas the compiler considers ‘a’ to be after ‘B’, since ‘B’ is capitalized, and it always puts capitalized letters first (presumably because capitalized letters come first in the character map))

D) I realized that I could find which file the ‘internal compiler error’ happened in by intentionally creating normal compile errors at the bottom of each file, in turn, until I saw the normal error not show up in the Console. (indicating that it came after the internal-compiler-error-causing line)

So now:

Tip #1) The technique.

If you get an ‘internal compiler error’:

  1. Place the following code at the very bottom of the first (alphabetically speaking) script file: (in other words, the top-most script file in the Project view)

    class CompileBreaker { public CompileBreaker() { var i = 0 / 0; } }

  2. If you still get the ‘internal compiler error’, then the issue is somewhere in the file. (you can try placing the CompileBreaker at the top, just to make sure) If not, then remove the CompileBreaker code from the file, and add it to the bottom of the next file.

  3. Repeating steps 1 and 2 for each script file, in alphabetical order.

The first time I used this technique, (which was just a few minutes ago), I was pretty lucky. I found the cause of my ‘internal compiler error’ in the second file, “Core.cs”. Which brings me to my next point, which is that…

Tip #2) The Mono compiler for Unity apparently has an issue with partial classes.

Here is the file I found to have caused the internal compiler error, with the error-causing line marked:

using System;

namespace ManagedLzma.LZMA.Master
{
    public static partial class LZMA // <<< the line that caused the 'internal compiler error'
    {
        [System.Diagnostics.Conditional("SHOW_DEBUG_INFO")]
        internal static void DebugPrint(string format, params object[] args)
        {
            System.Diagnostics.Debug.WriteLine(String.Format(format, args));
        }

        internal static void Print(string format, params object[] args)
        {
            System.Diagnostics.Debug.WriteLine(String.Format(format, args));
        }
    }
}

class CompileBreaker { int i = 0 / 0; } // my CompileBreaker code that wasn't reached

I removed the word “partial” from the line, and changed the class name to “LZMA_RenamedForNow”, and the compiler successfully reached the CompileBreaker code at the bottom. I then moved the CompileBreaker code to the next file, found the same issue (with it having “partial” class declarations), and fixed it. Moved the CompileBreaker to the next file. And so on.

Each time the CompileBreaker code is reached, you know the code up to that point is fine, so you just move it to the bottom of the next file.

It’s worked really well for helping me solve this sort of problem, that is otherwise almost pure guesswork. (before this I was trying to delete and comment out files and code blocks, but that became very difficult because the library with the issues has dozens of classes which are interlinked with each other–causing early, normal compile errors, that blocked my ability to see where the ‘internal compiler error’ was lying (since the ‘internal compiler error’ is only seen if it doesn’t encounter normal errors first))

Anyway, hope this helps anyone still having issues with finding where their project’s ‘internal compiler errors’ lie.

It could be one of many things, but when this happens for me, I just change a line of a script and then when I go back to unity it forces things to re-compile and it usually works for me the second try. CTRL + R is also a way to force reload. I didn’t see this mentioned as an advice in the comments.

I’m having the same issue with a different error message:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path “C:\Users\Corey\Documents\RTStutorial\Temp\Assembly-CSharp.dll.mdb” is denied.

It’ll happen with brand new projects - not an issue with the code. I tried re-installing Unity as Admin to no avail. Just started happening after 4.3 release.

For some people it’s an antivirus issue, but even with McAffee deactivated I can’t run my scripts. Major impediment to working, especially since I suck at coding to begin with.

Check your ‘yield’ commands with IEnumerator coroutines. There’s a bug I think in the mono compiler Unity uses. I had two in a branching if else statement. Each one on it’s own worked, both didn’t (even still inside the if statement). Might have something to do with normal return and yield return also.

For myself it was because McAfee was installed. I replaced it with Norton and have not had problems since.

if you have McAfee installed you will never get the window for unity that allows you to access your private network, it blocks it I changed from McAfee as well and have not seen the error.