System.MissingMethodException: Method not found: 'Microsoft.Extensions.Hosting.IHostBuilder Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.ConfigureAppConfiguration
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với phần triển khai PluginAssemblyLoadContext và lời gọi entry-point dựa trên reflection được thể hiện trong issue. Kiểm tra cách thư mục dependency của plugin và context mặc định resolve các assembly Microsoft.Extensions.Hosting, sau đó tái hiện đường dẫn khởi động. Được xem là hoàn tất khi plugin khởi động thông qua reflection mà không gặp MissingMethodException đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have two webapi programs (Main and Plugin) both developed using net9. To facilitate startup, I use the Main program and start the Plugin program through reflection. However, this error keeps occurring during startup. For the dependent programs, the versions of my two programs are the same.
// This is a collectible (unloadable) AssemblyLoadContext that loads the dependencies
// of the plugin from the plugin's binary directory.
public class PluginAssemblyLoadContext: AssemblyLoadContext
{
// Resolver of the locations of the assemblies that are dependencies of the
// main plugin assembly.
public AssemblyDependencyResolver _resolver;
private readonly string _mainAssemblyPath;
public PluginAssemblyLoadContext(string pluginPath) : base(isCollectible: false)
{
_resolver = new AssemblyDependencyResolver(pluginPath);
}
// The Load method override causes all the dependencies present in the plugin's binary directory to get loaded
// into the HostAssemblyLoadContext together with the plugin assembly itself.
// NOTE: The Interface assembly must not be present in the plugin's binary directory, otherwise we would
// end up with the assembly being loaded twice. Once in the default context and once in the HostAssemblyLoadContext.
// The types present on the host and plugin side would then not match even though they would have the same names.
protected override Assembly Load(AssemblyName assemblyName)
{
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
var assembly = LoadFromAssemblyPath(assemblyPath);
return assembly;
}
return null;
}
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
if (libraryPath != null)
{
return LoadUnmanagedDllFromPath(libraryPath);
}
return IntPtr.Zero;
}
}
var webApiAlc = new PluginAssemblyLoadContext(file);
Assembly assembly = webApiAlc.LoadFromAssemblyPath(file);
MethodInfo entryPoint = assembly.EntryPoint;
string[] methodParams = new string[] { path };
var result = entryPoint.Invoke(null, new object[] { methodParams });
Error message
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.MissingMethodException: Method not found: 'Microsoft.Extensions.Hosting.IHostBuilder
Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.ConfigureAppConfiguration(Microsoft.Extensions.Hosting.IHostBuilder, System.Action`1<Microsoft.Extensions.Configuration.IConfigurationBuilder>)'.
- Ngôn ngữ chính
- C#
- Star
- 3.7k
- Fork
- 5.1k
- Merge trung bình
- 19 giờ 47 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/samples
-
dotnet-target-version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
-
dotnet-target-version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
dotnet-target-version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Race condition in orleans/ShoppingCart/Grains/InventoryGrain.cs#L48Có thể đã có người làm @TimonPasslick đã nhận 160 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
dotnet-target-version
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Tất cả issue của dotnet/samples
Issue tương tự
-
Audit by ear: boss warnings, other not-enough messages, ailments and barriers in a chapter 1 battleĐang mởenhancement needs-game ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Sour-Dev-Home/metaphor-accessibility#1273 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
joinrpg/joinrpg-net#6336 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
muxinc/mux-csharp#88 ·
-
In-car displays show 0 km/h and P while the AV drivesCó thể đã có người làm @bazilinskyy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
bazilinskyy/coupled-sim#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 3 ngày