-
Notifications
You must be signed in to change notification settings - Fork 559
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
Weird TypeLoadException that only shows up in UWP? #2438
Comments
What's going on here? I added a reference to the latest version 4.4.1 of System.ServiceModel.Primitives along with auto binding redirects and I still get the same message. |
Hi @Joebeazelman! let me try to understand your scenario just to make sure we are on the same page:
The exception you are getting is definitely confusing, we need more data to be able to troubleshoot the issue. thank you! |
Hi Miguel, Thanks for all your help and responses. Let me address each of your questions:
[System.ServiceModel.FaultContractAttribute(typeof(ServiceReference1.ErrorDetailType[]), Action="http://whoop.com/webservices/WhoopBinding/v1.1", Name="Errors", Namespace="http://www.whoop.com/XMLSchema/XOLTWS/Error/v1.1")]
|
I want to add this as well: 1> Encountered conflict between 'Reference:C:\Users\mbarr.nuget\packages\microsoft.netcore.universalwindowsplatform\6.0.5\ref\uap10.0.15138\System.ServiceModel.Primitives.dll' and Choosing 'Reference:C:\Users\mbarr.nuget\packages\microsoft.netcore.universalwindowsplatform\6.0.5\ref\uap10.0.15138\System.ServiceModel.Primitives.dll' because AssemblyVersion '4.2.1.0' is greater than '4.1.1.0'. |
adding @zhenlan |
If all your assemblies are compiled against NS2.0, you should not need the shim. The shim is for the assemblies compiled against full framework to work on UWP/.NET Core. The conflicting error about Adding @mconnew to see if he has any suggestions to the issue you have. |
The reason I added the 4.4.1 shim is because the error message told me to.
I get the same error if I don't include it.
…On Wed, Dec 13, 2017 at 8:51 PM Zhenlan Wang ***@***.***> wrote:
Zhenlan claims Microsoft.NETCore.UniversalWindowsPlatform v6.0.4 package
already has the shim. Somehow, the shim isn't being applied to
FaultException.
If all your assemblies are compiled against NS2.0, you should not need the
shim. The shim is for the assemblies compiled against full framework to
work on UWP/.NET Core.
The conflicting error about System.ServiceModel.Primitives.dll is
expected. You should not reference
system.servicemodel.primitives\4.4.1-servicing-25917-01 package, which is
a servicing release. The system.servicemodel.primitives shipped in
microsoft.netcore.universalwindowsplatform\6.0.5 is a higher version one
and has more APIs.
Adding @mconnew <https://github.com/mconnew> to see if he has any
suggestions to the issue you have.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2438 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABxvjgCRq-t_3yPA7AjgxvxxMgC0n9ldks5tAH8KgaJpZM4Q8Xaq>
.
|
Can I get some feedback on this? Is there a workaround? |
Sorry I didn't reply sooner, I've been very busy on another time critical issue. I think the original message is the key here. We have a build step which generates a proxy class which implements your service interface. This is the type which gets instantiated when you call ChannelFactory.CreateChannel(). The runtime exception is saying that the service interface is not accessible to the proxy class that implements it. Is your service interface defined as either internal or private? When not running the native compilation toolchain, we use a different mechanism which creates the proxy class at runtime using refemit and this doesn't have the same accessibility limitations so code which works fine running managed could have this problem when natively compiled. |
@mconnew Thanks. This has solved the issue. I originally suspected the service interface to be the issue. I always generate my service interfaces as internal, since there is no reason to use them directly. So I shouldn't have turned on this otherwise innocent option. So it turns out Microsoft summons demon code in WCF. Emitting and executing additional proxy code outside the statically generated one is worthy of a Bozo Prize. Clearly, the responsible programmer passed the whiteboard interview, but failed to the piss cup test. In, other words, THIS IS A BUG! Shame on you Microsoft! |
Can you suggest a different way to have |
According to @mconnew, this is likely due to multi-file feature in UWP that the user-defined service interface and the toolchain-generated dispach proxy are in two different assemblies. |
I gave this a try with a UWP app created from template with VS 2017 v15.6.0 preview 4 and settings below
Then in the UWP app, I added WCF client proxy using "Add Service Reference" (note, this is not WCF connected services) against a WCF service that is also created just out of the template with settings below
The issue does not repro when the UWP app is built in either debug or release mode. Next, I will try to build the WCF proxy in a separate library project. |
Update: the issue does not repro when the WCF proxy is in a separate library project (either netstandard2.0 library or UWP library). |
I remember there is a setting to enforce multi-file feature in UWP project, but I cannot find it handy. This is what we should try next. @morganbr do you happen to know the UWP setting to enable multi-file feature? |
@morganbr Do you have any input? |
Sorry, I must have missed this the first time. In UWP, multi-file is on by default, but the msbuild property is |
That said, the exceptions above sound more like CoreCLR exceptions than .NET Native exceptions. I wonder if this is a Debug or Release issue. |
@morganbr , an assembly for the proxy is only generated when compiled to .NET Native. If this was running with CoreCLR, it would be using an in-memory temporary assembly created using RefEmit. I don't believe the original exception message matches what you would see with a refemit generated temporary assembly. Would you get a TypeLoadException from Ref Emit code on CoreCLR? |
I've confirmed it's CoreCLR. ProxyBuilder is used in the RefEmit implementation. That also matches an accessibility error since .NET Native never checks accessibility. |
@morganbr Is there a way to implement an internal Interface using RefEmit? |
Sorry, I don't know much about RefEmit. @atsushikan? |
|
@atsushikan, on .Net Framework we using transparent proxies with remoting to create our WCF proxy. This can dispatch calls for any interface method regardless of accessibility. Could we do something with a naming convention when creating the dynamic assembly/dynamic module along with InternalsVisibleToAttribute? Is there a way to have InternalsVisibleTo specify an assembly which is dynamically generated? I.e. someone has an internal interface MyNameSpace.IMyInterface so they add an InternalsVisibleTo attribute specifying a name which is derived from this, (e.g. "MyNameSpace.IMyInterface.DispatchProxy") which would enable the dynamic code to access the internal interface? |
I don't know but it's easy to set up an experiment to find out. |
Is there any fix/workaround for this issue? |
@JKennedy24 Is making the contract interface to be public a reasonable work around for you? |
@Lxiamail When you talk about the Contract Interface are you talking about the service side or client side? |
This is the exception I am seeing when using my WCF client class on UWP:
|
@JKennedy24 If the client side contract is already public, which sounds like a different issue than the original reported issue on this thread. #3088 may be closer. #3088 looks like a UWP project reference transit problem. UWP team is doing investigation. It would be helpful to confirm if you can share the repro project. |
@atsushikan, have you gotten chance to try out @mconnew's suggestion? |
Close this issue for now. Please feel free to reopen it if @mconnew's suggestion doesn't work for you. |
I have several assemblies containing WCF web services. They all work perfectly in my .NET Framework 4.6.2 MSTEST project. When I execute the same functions in my UWP application, I get the following exception for one of the projects, but not the others:
System.TypeLoadException
HResult=0x80131522
Message=Type 'generatedProxy_2' from assembly 'ProxyBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.
Source=
StackTrace:
Interestingly, I click on the exception for more information, I get the following:
It appears to be a different exception altogether. Which exception is correct and why the divergence? Also, why didn't the primitive types carry its references.
The text was updated successfully, but these errors were encountered: