dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.71k stars 559 forks source link

XAMARIN FORM consuming WCF error #3031

Open Robertbe opened 6 years ago

Robertbe commented 6 years ago

Dear support,

I am register an DOT net WCF service, and trying to consume it through Xamarin CPL. I got this error when start calling the service. I have upgrade the System.ServiceModel.Primitives to 4.5.2 but still not help.

==================================

{System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.5.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'System.ServiceModel.Primitives, Version=4.5.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at ADATimeSheet.ViewModels.TimesheetDetailViewModel.<>c.<<-ctor>b__9_2>d.MoveNext() at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine) at ADATimeSheet.ViewModels.TimesheetDetailViewModel.<>c.<.ctor>b__9_2(TimesheetDetailPage obj, Timesheet tsheet)

}

StephenBonikowsky commented 6 years ago

@Robertbe WCF in Xamarin is a separate code base than what we support in this repo, but could you clarify your scenario a bit? Did your scenario work at all? If so, what version of System.ServiceModel.Primitives were you using when it worked?

jupagose commented 6 years ago

I have a similar problem but in my case Async methods generated by Microsoft WCF Web service reference provider can't be consumed from XAMARIN

If I made a call like this

string response = await client.GetIdentificationTypesAsync();

I get this:

Error in deserializing body of request message for operation 'GetIdentificationTypes'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetIdentificationTypes' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'GetIdentificationTypesAsync' and namespace 'http://tempuri.org/'

If I fix REFERENCES manually I can consume sync Methods but not Async ones.

StephenBonikowsky commented 6 years ago

@jupagose your issue is not the same as what @Robertbe is reporting. Your issue is because Xamarin actually has its own implementation of WCF taken from WCF full framework a number of years ago so while WCF in the full framework and WCF Core here in this repo has continued to evolve the code in Xamarin has not. What you are reporting is one of the affected areas.

This issue #2463 contains more info on this.

jiayi11 commented 6 years ago

Hi @Robertbe, could you provide us more details of this issue so we can understand your scenario better? Did your project work well before but the issue suddenly happen because of a recent upgrade of package? Could you try to upgrade the packages to 4.5.3 to see if it works?

jupagose commented 6 years ago

Actual xamarin versions doesn't work with latests version of wcf clients.

Just try to consume a wcf service client generated with vs studio 2017 latests update. If you want code sample i can submit. I'm not the only one with this problem.

Seems https://github.com/dotnet/wcf/issues/2463 is the problem but looks like xamarin team doesn't care about it.

Tks for take the time to answer

Robertbe commented 6 years ago

Hi @Robertbe, could you provide us more details of this issue so we can understand your scenario better? Did your project work well before but the issue suddenly happen because of a recent upgrade of package? Could you try to upgrade the packages to 4.5.3 to see if it works?

Hi Lxiamail, Thanks for replying to my issue. I have upgrade to 4.5.3 and still not working. I ends up abandoning WCF and rewrite the project to use Web API back-end instead.

Regards,

Robert

Lxiamail commented 6 years ago

@Robertbe I'm sorry to hear that. We have been working with UWP team to investigate the issue, but there is no conclusion yet.

Robertbe commented 6 years ago

Thanks for checking into the issue.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Alicia Li notifications@github.com Sent: Wednesday, October 3, 2018 3:01:54 PM To: dotnet/wcf Cc: Robert Be; Mention Subject: Re: [dotnet/wcf] XAMARIN FORM consuming WCF error (#3031)

@Robertbehttps://github.com/Robertbe I'm sorry to hear that. We have been working with UWP team to investigate the issue, but there is no conclusion yet.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/wcf/issues/3031#issuecomment-426800979, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARqEgTCzJXNEbYsXLEb9vPU59fxYPlf9ks5uhSXCgaJpZM4VRpZl.

Lxiamail commented 5 years ago

Created a UWP bug#727016 to track this issue

Robertbe commented 5 years ago

I finally abandon the WCF and use Web API instead. All working like a charm for all XAMARIN project include iOS and Android.

KonstantinosP7 commented 5 years ago

I have the same issues with WCF. I have created succesfully the WCF service, tested it on browser, tested it on UWP , everything works, but when I set as start up project the android.app, it throws system error when trying to communicate with the service. (in away client command). Any simple Web API example to communicate with xamarin android app? Thank you in advance, I am in really urgent situation.

Lxiamail commented 5 years ago

Looks like there are a few different problems reported in this issue.

  1. We couldn’t repro the “assembly System.ServiceModel.Primitives load error”, it is the original problem reported by Robertbe
  2. The problem reported by @jupagose is the XAMARIN issue #2463 .
  3. @KonstantinosP7 Sorry for the delay response. Is your issue similar as the async method name mis-match as @jupagose reported?
pavloss commented 4 years ago

I'm experiencing the same issue as the OP. I have a PCL that has consumed a WCF service. In the xamarin forms UWP project I have referenced this class library version 6.2.10. On debugging or running this project i get the following:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.'