Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The assembly update failed. #73173

Open
NMSAzulX opened this issue Apr 22, 2024 · 8 comments
Open

The assembly update failed. #73173

NMSAzulX opened this issue Apr 22, 2024 · 8 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@NMSAzulX
Copy link

Version Used:

Steps to Reproduce:

Console.WriteLine(MetadataUpdater.IsSupported); //True
Console.WriteLine(Debugger.IsAttached); //False

//Dynamic Compile - Get New Assembly Stream
 var compileResult = _compilation.Emit(
    dllStream,
    pdbStream: pdbStream,
    xmlDocumentationStream: xmlStream,
    metadataPEStream: metaStream
    );
 LogCompilationEvent?.Invoke(_compilation.GetNatashaLog());

//Update
 if (compileResult.Success)
 {
     var ilDelta = AsReadOnlySpan(dllStream);
     var pdbDelta = AsReadOnlySpan(pdbStream);
     var metadataDelta = AsReadOnlySpan(metaStream);
     MetadataUpdater.ApplyUpdate(oldAssembly, metadataDelta, ilDelta, pdbDelta);
 }

static ReadOnlySpan<byte> AsReadOnlySpan(Stream input)
{
    input.Seek(0, SeekOrigin.Begin);
    using MemoryStream ms = new MemoryStream();
    input.CopyTo(ms);
    return ms.GetBuffer().AsSpan();
}
//old assembly:
public class A{  public int Code = 1; public void Show(){ Console.WriteLine(Code);  }   }
//new assembly:
public class A{  public int Code = 2; public int Code1 = 0; public void Show(){ Console.WriteLine(Code);  }   }

InvalidOperationException : The assembly update failed.

Diagnostic Id:

Expected Behavior:
The assembly update succeed.

Actual Behavior:
The assembly update failed.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 22, 2024
@CyrusNajmabadi
Copy link
Member

Could you clarify which part of roslyn you think is involved here? Thanks!

@NMSAzulX
Copy link
Author

@CyrusNajmabadi Hot reload, Enc, IL and metadata are all related to Roslyn. I don't know if the dynamic compilation of the code I mentioned above is correct. Do you recommend doing this? For the hot reload technology, only the MetadataUpdater.ApplyUpdate method is provided by DotNet, but I first consider that it may be a problem with IL and metadata. Or do you have any recommended practices? Actually, I also don't know how to debug it, and I can't collect more detailed information. Hope to get your help, thank you.

@CyrusNajmabadi
Copy link
Member

Tagging @tmat

@NMSAzulX
Copy link
Author

@tmat Hello. Could you help me solve this problem?

@NMSAzulX
Copy link
Author

What should I do with this ISSUE? Who can reply to me? Is Tmat on vacation? When do I need to wait? Is there a roughly time?

@NMSAzulX
Copy link
Author

Why is it so difficult to ask questions to Roslyn every time? Isn't code the simplest and most straightforward way? What else do I need to do?

@CyrusNajmabadi
Copy link
Member

What should I do with this ISSUE?

You could try debugging through the scenario and seeing where it failed.

Why is it so difficult to ask questions to Roslyn every time?

I see one other time you've interacted in this repo. What other questions are you having issues with?

What else do I need to do?

Consider debugging through and seeing where things are failing. That may help you figure out what needs to be done to solve the issue. You could also try askign questions in some of the .net discords. Though i don't know if anyone there happens to know much about this subject area.

Is there a roughly time?

This is not a support forum. You can open issues, but team members may or may not respond to them depending on their work and schedules. I recommend being friendly, constructive, and try to get as much info to help narrow down what might be going on. But even then, it may not be the case that any resolution happens in any short time frame as everyone is generally very busy with very full plates.

@NMSAzulX
Copy link
Author

Thank you for your suggestion. The actual situation is that none of the other websites can be accessed here. I'll think of other ways. For now, hot reload can only be used in Debug mode, and this function is only limited to debugging use, and perhaps the priority is not very high. I just want to learn more about this technology. I also know that adding this technology to the development code would be somewhat strange. Last year, I also raised related questions. I want to say that each of us is incurring the cost of time, especially in the face of related technologies of Roslyn. If a problem goes beyond my ability scope, I will also be very distressed. Please understand each other. Thank you again for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants