dotnet / dotnet/aspnetcore

Hot Reload: unable to call added public API

Open
#36,356 18 comments 0 reactions 0 assignees View on GitHub
area-commandlinetools feature-hot-reload
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Description

Calling a public method added to a referenced library during Hot Reload may throw `System.MissingMethodException`.

Repro:
Run App.exe, uncomment the commented code and apply changes. If both changes are applied at the same time the exception is thrown. If the method is added first and then the caller is updated it works. Seems like the changes should be applied in topological order based on assembly references.

App.exe:

```C#
class Program
{
static void G()
{
var c = new LibClass();
// Console.WriteLine(c.F()); // uncomment during Hot Reload session
}

static void Main(string[] args)
{
while (true)
{
Thread.Sleep(500);
G();
}
}
}
```

Lib.dll referenced by App.exe

```C#
public class LibClass
{
// uncomment during Hot Reload session
// public int F() => 1;
}
```

### Configuration

.NET 6.0.100-preview.6.21355.2
Windows 10

### Regression?

No.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.