WPFUser
WPFUser

Reputation: 403

CSC.exe throws "Process is terminated due to StackOverflowException" when compiling

I am using Entity Framework 4.0

Upon creating a new class with just over 1k properties I get a problem after creating the migration package. When trying to compile the project I get Build Failed. "csc.exe has exited with code 255"

When looking more into the details I see this msg in the build log:

Using "Csc" task from assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.CodeAnalysis.dll". 1>Task "Csc" 1> C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:... 1>
1> Process is terminated due to StackOverflowException. 1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.Core.targets(67,5): error MSB6006: "csc.exe" exited with code 255.

Obviously the Up() method in the migration script creates a really big CreateTable method. I assume that to be the problem. I'm not quite sure though.

Is it actually not possible to have a class with this many fields when using EF?

Update: The model class is in a separate project and compiles fine. The problem is with the migration method.

It's also autogenerated and looks something like this:

public partial class CustomClass : DbMigration
{
    public override void Up()
    {
        CreateTable(
            "dbo.GeneratedClasses",
            c => new
                {
                    RowId = c.Int(nullable: false, identity: true),
                    RecordTime = c.DateTime(nullable: false),
                    Prop1 = c.Decimal(nullable: false, precision: 18, scale: 2),
                    Prop2 = c.Decimal(nullable: false, precision: 18, scale: 2),
                    Prop3 = c.Decimal(nullable: false, precision: 18, scale: 2),

...

                    PropN= c.Decimal(nullable: false, precision: 18, scale: 2),
                })
            .PrimaryKey(t => t.RowId);

    }

Upvotes: 1

Views: 1482

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 156938

More than 1000 properties in a class seems too much to me, really!

That put aside, the issue is most likely not that. A StackOverflowException indicates endless recursion. There might be a EF field / property that references itself, thus creating an endless loop.

I suggest to disable a few fields, try if it compiles then, and keep doing that until you find the offending line.

Upvotes: 2

Related Questions