question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutOfMemoryException (lots of large winforms designer files)

See original GitHub issue

Steps to reproduce

  1. I downloaded and installed latest version 8.4.6.0 from https://marketplace.visualstudio.com/
  2. I opened my VB.net project in VS2019 and right-clicked “Convert to C#”. The project has around 1200 VB forms including designer forms. Phase 1 was completed after 7 hours with having one error in one form.
  3. Phase 2 started, after around 40 forms I got the following error.

Error message shown

https://github.com/dotnet/roslyn threw an exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Resize()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.CreateEntry(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.GreenNode..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CastExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CastExpressionSyntax.<>c.<.cctor>b__24_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InvocationExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InvocationExpressionSyntax.<>c.<.cctor>b__18_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ExpressionStatementSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ExpressionStatementSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithManyChildrenBase..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithLotsOfChildren.<>c.<.cctor>b__0_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BlockSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BlockSyntax.<>c.<.cctor>b__24_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MethodDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MethodDeclarationSyntax.<>c.<.cctor>b__45_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithManyChildrenBase..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithLotsOfChildren.<>c.<.cctor>b__0_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ClassDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ClassDeclarationSyntax.<>c.<.cctor>b__45_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.NamespaceDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.NamespaceDeclarationSyntax.<>c.<.cctor>b__42_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax.<>c.<.cctor>b__27_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode.DeserializeFrom(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.DeserializeNodeFrom(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.AbstractSyntaxTreeFactoryService.RecoverableSyntaxRoot`1.RecoverRoot(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.AbstractSyntaxTreeFactoryService.RecoverableSyntaxRoot`1.Recover(CancellationToken cancellationToken)
   at Roslyn.Utilities.AsyncLazy`1.GetValue(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.WeaklyCachedRecoverableValueSource`1.GetValue(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.GetRoot(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.GetRootCore(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.GetSyntax(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.AddDeclaredNontypeMembers(DeclaredMembersAndInitializersBuilder builder, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.<BuildMembersAndInitializers>g__buildDeclaredMembersAndInitializers|152_1(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.<BuildMembersAndInitializers>g__getDeclaredMembersAndInitializers|152_0()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.BuildMembersAndInitializers(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersAndInitializers()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.MakeAllMembers(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersByNameSlow()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersByName()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembers(String name)
   at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.GetConstructors(Boolean includeInstance, Boolean includeStatic)
   at Microsoft.CodeAnalysis.CSharp.Binder.GetAccessibleConstructorsForOverloadResolution(NamedTypeSymbol type, Boolean allowProtectedConstructorsOfBaseType, ImmutableArray`1& allInstanceConstructors, CompoundUseSiteInfo`1& useSiteInfo)
   at Microsoft.CodeAnalysis.CSharp.Binder.TryPerformConstructorOverloadResolution(NamedTypeSymbol typeContainingConstructors, AnalyzedArguments analyzedArguments, String errorName, Location errorLocation, Boolean suppressResultDiagnostics, BindingDiagnosticBag diagnostics, MemberResolutionResult`1& memberResolutionResult, ImmutableArray`1& candidateConstructors, Boolean allowProtectedConstructorsOfBaseType)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(SyntaxNode node, String typeName, SyntaxNode typeNode, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, InitializerExpressionSyntax initializerSyntaxOpt, TypeSymbol initializerTypeOpt, Boolean wasTargetTyped)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, String typeName, BindingDiagnosticBag diagnostics, TypeSymbol initializerType)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindObjectCreationExpression(ObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindInferredVariableInitializer(BindingDiagnosticBag diagnostics, ExpressionSyntax initializer, BindValueKind valueKind, RefKind refKind, CSharpSyntaxNode errorSyntax)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindVariableDeclaration(SourceLocalSymbol localSymbol, LocalDeclarationKind kind, Boolean isVar, VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, TypeWithAnnotations declTypeOpt, AliasSymbol aliasOpt, BindingDiagnosticBag diagnostics, Boolean includeBoundType, CSharpSyntaxNode associatedSyntaxNode)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindDeclarationStatementParts(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindLocalDeclarationStatement(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlock(BlockSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, VariableState nullableInitialState, ImportChain& importChain, Boolean& originalBodyNested, InitialState& forSemanticModel)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass23_0.<CompileNamedTypeAsync>b__0()

https://github.com/dotnet/roslyn threw an exception: System.InvalidOperationException: Exception of type 'System.InvalidOperationException' was thrown.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.GreenNode..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sanketgroupcommented, Mar 12, 2022

It’s VB. Net to c# .Net 4.5.2

0reactions
GrahamTheCodercommented, Apr 14, 2022

Consolidated into other issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

Out of Memory Exception when handling large files in C# - ...
My problem occurs when the user selects an unusually large amount of text files like 1264 text files total size up to 750MB,...
Read more >
OutOfMemoryException int the Visual Studio Designer
Hi! Recently in all view of my application, i'm getting the error that you can see in the attached image: Each time that...
Read more >
Troubleshoot Out of Memory issues - ASP.NET
If the operating system is unable to satisfy the GC's request for a contiguous block of memory, a System. OutOfMemoryException (OOM) occurs.
Read more >
C# - Out of Memory Exception
OutOfMemoryException when initializing a list of objects. To me this seemed pretty much impossible because my machine has 4GB RAM.
Read more >
OutOfMemoryException Class (System)
When data structures or data sets that reside in memory become so large that the common language runtime is unable to allocate enough...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found