Every now and then when I build a specific solution, I\'ll get a random amount of \"An expression is too long or complex to compile\" in the Error List window. However, the
When building you can see the the build output the last folder it checks before it fails. I removed the files in that folder and brought them back one by one. Finally found the issue. I dont know exactly what it is but it was a .aspx page with lots of HTML. It wasnt used often so I just removed it from the project and now it compiles.
I got this error in one project when I switched from Visual Studio 2012 to Visual Studio Community 2013.
In my case it was giant file (25k lines, not written by me) with had List<string[]>
initialized by collection initializer.
Something like this:
public class Class
{
public List<string[]> BigList
{
get
{
return new List<string[]>()
{
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
.
.
.
.
.
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"}
}
}
}
}
I changed it to string[][]
and the project started to compile
public class Class
{
public string[][] BigList
{
get
{
return new string[][]
{
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
.
.
.
.
.
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"},
new string[]{"foo","bar"}
}
}
}
}
I can share our experience with this error. Typical Microsoft masterpiece (or just a piece...) Our problem was actually due to too many DLLs for IIS to compile. Diagnosing it was a pain (as diagnostics is nonexistent). Removing some unnecessary DLLs (like unit test DLLs) from the main BIN folder has gotten rid of the problem. Go figure...
I have never seen this in the wild.
However, from googling around it may well be from an excess of assembly references, one particular quote:
If I reduce number of referenced assemblies to 5500 it is compiled and working
Now, surely, you would have noticed a dependency list that large, could you check whether you have an overly large number of assemblies referenced?
FYI, that error is characteristic of the compiler running out of stack space. Typically that happens when you throw a "deep recursion" problem at the compiler, like say,
int x = (1 + (1 + (1 + (1 + ......... + 1 ) + 1 ) + 1 ) + 1);
say, several thousand deep. The syntactic and semantic analyzers are both recursive-descent analyzers and therefore prone to running out of stack space in extreme scenarios.
I have no idea why shutting down and starting over would affect that, though. That is really strange.
If you get a solid repro, I'd love to see it. Either post it here, or enter a bug on Connect and we'll have a look at it. Without a solid repro though it is very hard to say what is going on here.
I had the same problem in a 64-bit machine (VS 2012).
I used @MikeFlynn's answer to locate the folder causing the error.
Finally I discovered I had a Help.aspx page with no code behind - just HTML but it had multiple icon images embedded as base 64
<img src="data:image/png;base64 ... />
I converted it to static HTML and it compiled.
P.S. The same project was compiling O.K. in a 32-bit VS2012 machine. Both machines were running Windows 7.