-
Notifications
You must be signed in to change notification settings - Fork 565
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
System.NotSupportedException when using Hot Reload (VS 2022 - .NET 6) #4789
Comments
I am also receiving this exception, but it seems rather random as towards when it occurs. Tried to recreate it by hot reloading, but it is rather hit or miss whether it works. |
Okay, I narrowed it, it occurs on a hot reload when you change something in the controller on the page that is opened. (when you change something in another controller and hotreload, it does not occurs). Once you hot reload it, the system will keep giving the system not supported exception until you restart the application. |
After talking to a few colleagues, I believe I know how to fix this. In MethodInfoOperationSelector we use the MethodInfo object obtained by reflection during ChannelFactory creation to lookup which operation is for that MethodInfo. When hot reload happens, the CLR invalidates some MethodInfo types from it's cache which means a fresh lookup of the MethodInfo will yield a different instance. We should be able to make a simple change to use MethodInfo.MethodHandle.Value as the key instead. I've been told by those who know more about this than me that the method handle value should be stable. We don't actually need the MethodInfo object for anything in this code path so this should be sufficient. We do use MethodInfo.Invoke to execute callback contracts, but looking at the implementation, the Invoke call happens via the MethodHandle.Value so should continue to work. |
VS feedback:
https://developercommunity.visualstudio.com/t/SystemNotSupportedException-when-using/1663264?space=8&q=wcf+hot+reload
I get a System.NotSupportedException when using Hot Reload in an ASP.NET Core MVC (.NET 6) project with a WCF service reference.
Exception
Stack Trace
Sample project
MvcCore6WcfTest.zip
Screenshots

Additional context
The ASP.NET MVC project and the WCF service project were created using the default templates.
The text was updated successfully, but these errors were encountered: