Skip to content

[HR] ArgumentExcption on update #20438

Open
Open

Description

@jeromelaban

@MartinZikmund mine breaks also on hotreload after I edited Bindings, but with a different error message, is that somehow related to your issue?

16:57:23.15 Code changes were successfully applied.
17:04:38.95 [Error] Exception while emitting update: System.ArgumentException: An item with the same key has already been added. Key: Microsoft.CodeAnalysis.Emit.EditAndContinue.DeletedPEMethodDefinition
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.SerializeLocalVariablesSignature(IMethodBody body)
   at Microsoft.Cci.MetadataWriter.SerializeMethodBodies(BlobBuilder ilBuilder, PdbWriter nativePdbWriterOpt, Blob& mvidStringFixup)
   at Microsoft.Cci.MetadataWriter.BuildMetadataAndIL(PdbWriter nativePdbWriterOpt, BlobBuilder ilBuilder, PooledBlobBuilder& mappedFieldDataBuilder, PooledBlobBuilder& managedResourceDataBuilder, Blob& mvidFixup, Blob& mvidStringFixup)
   at Microsoft.Cci.MetadataWriter.WriteMetadataAndIL(PdbWriter nativePdbWriterOpt, Stream metadataStream, Stream ilStream, Stream portablePdbStreamOpt, MetadataSizes& metadataSizes)
   at Microsoft.CodeAnalysis.Compilation.SerializeToDeltaStreams(CommonPEModuleBuilder moduleBeingBuilt, DefinitionMap definitionMap, SymbolChanges changes, Stream metadataStream, Stream ilStream, Stream pdbStream, ArrayBuilder`1 updatedMethods, ArrayBuilder`1 changedTypes, DiagnosticBag diagnostics, Func`2 testSymWriterFactory, String pdbFilePath, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CompilationTestData testData, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditSession.EmitSolutionUpdateAsync(Solution solution, ActiveStatementSpanProvider solutionActiveStatementSpanProvider, UpdateId updateId, CancellationToken cancellationToken)
17:04:38.96 [Error] C:\Users\Sonja\source\repos\DevTKSS\DevTKSS.Uno.SampleApps\src\DevTKSS.Uno.Samples.sln (line 1): error ENC1002: Cannot apply changes -- unexpected error: 'An item with the same key has already been added. Key: Microsoft.CodeAnalysis.Emit.EditAndContinue.DeletedPEMethodDefinition'
17:04:38.96 Invalid changes were found. Please refer to the Error List window to fix those issues.
17:05:29.70 [Error] Exception while emitting update: System.ArgumentException: An item with the same key has already been added. Key: Microsoft.CodeAnalysis.Emit.EditAndContinue.DeletedPEMethodDefinition
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.SerializeLocalVariablesSignature(IMethodBody body)
   at Microsoft.Cci.MetadataWriter.SerializeMethodBodies(BlobBuilder ilBuilder, PdbWriter nativePdbWriterOpt, Blob& mvidStringFixup)
   at Microsoft.Cci.MetadataWriter.BuildMetadataAndIL(PdbWriter nativePdbWriterOpt, BlobBuilder ilBuilder, PooledBlobBuilder& mappedFieldDataBuilder, PooledBlobBuilder& managedResourceDataBuilder, Blob& mvidFixup, Blob& mvidStringFixup)
   at Microsoft.Cci.MetadataWriter.WriteMetadataAndIL(PdbWriter nativePdbWriterOpt, Stream metadataStream, Stream ilStream, Stream portablePdbStreamOpt, MetadataSizes& metadataSizes)
   at Microsoft.CodeAnalysis.Compilation.SerializeToDeltaStreams(CommonPEModuleBuilder moduleBeingBuilt, DefinitionMap definitionMap, SymbolChanges changes, Stream metadataStream, Stream ilStream, Stream pdbStream, ArrayBuilder`1 updatedMethods, ArrayBuilder`1 changedTypes, DiagnosticBag diagnostics, Func`2 testSymWriterFactory, String pdbFilePath, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CompilationTestData testData, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditSession.EmitSolutionUpdateAsync(Solution solution, ActiveStatementSpanProvider solutionActiveStatementSpanProvider, UpdateId updateId, CancellationToken cancellationToken)
17:05:29.70 [Error] C:\Users\Sonja\source\repos\DevTKSS\DevTKSS.Uno.SampleApps\src\DevTKSS.Uno.Samples.sln (line 1): error ENC1002: Cannot apply changes -- unexpected error: 'An item with the same key has already been added. Key: Microsoft.CodeAnalysis.Emit.EditAndContinue.DeletedPEMethodDefinition'
17:05:29.70 Invalid changes were found. Please refer to the Error List window to fix those issues.
17:05:40.46 DevTKSS.Uno.Samples.MvuxGallery (3):16952: The process has exited.
17:05:40.46 DevTKSS.Uno.Samples.MvuxGallery (3): Hot Reload session complete.

I dont know under which caption I should list this instead maybe you have a suggestion if its not same.
Github dont lets me add the repro without bin and obj as zip here, but you can get it from my Repository directly

the nuget its "missing" then is content of my Extensions PR, but packed it here:

nuget DevTKSS.Extensions.Uno.1.0.0-preview.1.0.0.zip

Originally posted by @DevTKSS in #20375

Activity

  1. jeromelaban commented on May 16, 2025

    @jeromelaban
    MemberAuthor

    Thanks for the report@DevTKSS.

    Could you tell which version of Visual Studio you are using? Specifically, the issue is in visual studio and can't fix on our own, but it's extremely important to have exact repro steps so we can report it to Microsoft.

  2. added theissue type on May 16, 2025
  3. added
    area/hot-reload
    project/core-tools 🛠️
    on May 16, 2025
  4. DevTKSS commented on May 16, 2025

    @DevTKSS
    Contributor

    vs 2022 Community Edtion Version is the latest 17.4.0 just today before this
    for the repro steps: in my opinion, my steps has been very normal...

    In the CounterPage, I did see my Increment by Step Size Binding has been defect,
    I thought I might had deleted a State in my Model, so I added one (type int), tryed to insert it to the Value (as you will know, that did not work ;) - no HotReload inbetween, just compiler unsatisfyed ) then I checked the mvux - xaml docs for the counter workshop for this, deleted the added state and default value edit in the model.
    then in the Page I did update

    • the Increment TextBox (first one in the Stackpanel) Binding to the Countable.Step, no idea why it wasnt like this before, since I thought it did work.
    • the TextBlock below the TextBox which is showing the Counter Value. I did initially create this Counter Page with HotDesign I think so there was of course no binding and just the Counter Value till that point. I removed the Text Binding and added the Run Text elements in line 37 of this Page
    • added the Padding on the Button Below because just with Margin that was not as pretty as I wanted it to be 😅

    THEN I clicked the Hot Reload Button and BANG... Exception, not willing to be recovered, not giving me any idea what I might did wrong to make it Break like this.

    Hoping this helps you investigate it...? I dont think I have more details I could tell you.

    Uno.Sdk version is and was the current 6.0.67.
    the only remarkable difference I seen in this application to one created with the new released wizard Templates is, that when you resize this linked application WIDTH and look onto the NavigationView Header, the MenuPaneOpen Button just vanishes out of sight until you upscale the width again
    That somehow does not happen in a app with the new templates using, which I showed for a misalignment and style issue in the Uno.Themes repo because I think the main issue there is defintly a Material Theme issue:
    unoplatform/Uno.Themes#1545

  5. DevTKSS commented on May 16, 2025

    @DevTKSS
    Contributor

    PS: seems like for the vanished MenuPaneToggle Button is the depending Visible property set to false the culprit I did not see I set like this. I defintly have to get a ResponsiveExtension.Narrow listener added to this 😅

  6. DevTKSS commented on May 19, 2025

    @DevTKSS
    Contributor

    Getting quite very often exceptions similar to this (will inspect the output more closely if needed in future, most time just restarting app debug...) closely related to when I change something with State/ListFeed in the model record (99% I have to restart to get those changes appyed) and then trying to use binding via the view.

    I would normally not expect that hotreload is not reliable usable with mvux state things🤔 or did I miss this information?

  7. github-actions commented on May 12, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  8. added
    stale
    on May 12, 2026
  9. removed
    stale
    on May 12, 2026
  10. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  11. added
    stale
    on Oct 28, 2026
  12. removed
    stale
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/hot-reloadproject/core-tools 🛠️

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions