-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
We have a plugin loaded using AssemblyLoadContext. This plugin calls a WCF service orignially generated by dotnet-svcutil.
Under net9.0 we noticed what appears to be a regression. When the channel is created System.ServiceModel tries to generate a proxy. This fails with a FileNotFoundException indicating that the plugin assembly cannot be found. The error message shows a PublicKeyToken with a random value on each attempt.
The PublicKeyToken value is unexpected, it should be null since none of the assemblies are signed.
We tried various combinations of TargetFramework values for the involved projects. The results are summarized below.
| ConsoleApp1 | Contracts | Plugin1 | Result |
|---|---|---|---|
net8.0 |
net8.0 |
net8.0 |
✅ WORKS |
net8.0 |
netstandard2.0 |
net8.0 |
✅ WORKS |
net9.0 |
net9.0 |
net8.0 |
🚨 FAILS |
net9.0 |
netstandard2.0 |
net9.0 |
🚨FAILS |
Reproduction Steps
I attached a minimal repro extracted from the actual application which is impacted by this issue.
It contains the following:
- ConsoleApp1: loads and calls the plugin
Plugin1 - Plugin1: contains the WCF call
- WcfServiceSimulator: contains a web api which returns a mocked SOAP response
To reproduce the issue:
- Install .NET SDK 9.0 RC1 (
net9.0.100-rc.1.24452.12) cd ./WcfServiceSimulatoranddotnet runcd ./ConsoleApp1anddotnet run
Expected behavior
The expected output when running dotnet run --project .\ConsoleApp1 using net8.0 is:
TargetFramework is .NET 8.0.
Plugin "PluginId@1.0" dynamically loaded from "Plugin1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
Calling WCF Service using a dynamically loaded Assembly.
Response from http://localhost:7261/sdk was successful. Info.Name: Simulator
Actual behavior
When executing dotnet run --project .\ConsoleApp1 using net9.0, an unhandled exception is thrown.
TargetFramework is .NET 9.0.
Plugin "PluginId@1.0" dynamically loaded from "Plugin1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
Calling WCF Service using a dynamically loaded Assembly.
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Plugin1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=10000000fc7f0000'. The system cannot find the file specified.
File name: 'Plugin1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=10000000fc7f0000'
at System.Reflection.Emit.RuntimeTypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.RuntimeTypeBuilder.CreateTypeInfoImpl()
at System.Reflection.DispatchProxyGenerator.ProxyBuilder.CreateType()
at System.Reflection.DispatchProxyGenerator.ProxyAssembly.GetProxyType(Type baseType, Type interfaceType, String interfaceParameter, String proxyParameter)
at System.Reflection.DispatchProxyGenerator.CreateProxyInstance(Type baseType, Type interfaceType, String interfaceParameter, String proxyParameter)
at System.Reflection.DispatchProxy.Create[T,TProxy]()
at System.ServiceModel.Channels.ServiceChannelProxy.CreateProxy[TChannel](MessageDirection direction, ServiceChannel serviceChannel)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateProxy[TChannel](MessageDirection direction, ServiceChannel serviceChannel)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel[TChannel](EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannelInternal()
at System.ServiceModel.ClientBase`1.get_Channel()
at DummyServiceClient.RetrieveServiceContent(ManagedObjectReference _this) in C:\Repos\Issues\ne9-wcf-proxy\ConsoleApp1\Plugin1\DummyService.cs:line 102
at Plugin1.Plugin1Entrypoint.HandleRequest() in C:\Repos\Issues\ne9-wcf-proxy\ConsoleApp1\Plugin1\Plugin1Entrypoint.cs:line 44
at Program.<Main>$(String[] args) in C:\Repos\Issues\ne9-wcf-proxy\ConsoleApp1\ConsolePlugin\Program.cs:line 35
Regression?
This worked as expected on net8.0.
Known Workarounds
No response
Configuration
- .NET:
net9.0.100-rc.1.24452.12 - OS: Windows 11 Pro
- Arch: ARM64, x64
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status