XAMARIN PCL consumming WCF - c#

I'm developping in Xamarin PCL a project cross-platform I'm testing on IOS and android with Visual studio 2015 V4.6. I need to include System.ServiceModel In my portable Class to consume WCF Services. I can't Include it with Nuget Packets.
Could not install package 'System.ServiceModel.Primitives 4.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I tried to include directly Right clic on References -> path->System.ServiceModel[4.0.0.0] and then add*
I have this error message
' Severity Code Description Project File Line Suppression State
Error Can not resolve reference: /Users/ludovic/Library/Caches/Xamarin/mtbs/builds/DemoHandyLife.iOS/725fe7b4d3cb829a82e1002d425b8f86/bin/iPhoneSimulator/Debug/System.EnterpriseServices.Wrapper.dll DemoHandyLife.iOS C:\Program Files\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 696'
If I add System.ServiceModel[5.0.0.0] I have these Error Message
Error CS0012 The type 'CookieContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
Error CS0012 The type 'CookieContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
I tried to add the system.Net Version=5.0.5.0 automatically but nothing happen.
Can someone Help me? Thanks in advance
Tell me if you need more details.
Thanks in advance for your help.

Hello you can't directly add your WCf service to your Portable class library, I suggest to convert your wcf Service in a wcf rest Service. I let you watch the tutorial
or you can follow this tutorial if you absolutely want wsdl service. you can add it directly in your pcl class with the last xamarin version
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_WCF/

Related

OpenSilver with Service References

Im trying to migrate a Silverlight application to OpenSilver.
The application uses WCF service references that are included in the project.
I followed the OpenSilver example on migrating from Silverlight to OpenSilver
https://doc.opensilver.net/documentation/migrate-from-silverlight/example.html
After wrapping the application with the OpenSilver files I get an error that my services namespace could not be found, then when trying to add that missing service reference to the project I get "The target framework 'netcoreapp2.0' is out of support"
Is there a step I am missing in setting this up?
If you get the error because you copy-pasted the server references as well
If you double click that error it should bring you to the Reference.svcmap file of your WCF service reference. Find the Reference.cs file in Solution Explorer next to Reference.svcmap.
Open it and you will see the same error multiple times in the code:
"The type name 'IHttpCookieContainerManager' could not be found in the namespace 'System.ServiceModel.Channels'. This type has been forwarded to assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly."
Solution: add the following nuget package: System.ServiceModel.Http
If you try to add a new service reference then follow this workaround: https://github.com/dotnet/wcf/issues/4766#issuecomment-1007859628
I hope that helps.

.net5 windows api calls with CSWinRT

I am using the Windows.Devices.Bluetooth library in a WPF application using the .net 5.0 framework.
I have referenced the windows api by installing the CSWinRT nuget and using the target framework moniker in my csproj file like this:
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
This is instead of adding references to windows.winmd and windowsruntime.dll as you had to do pre-.net5. I am able to use the windows library with no problem, but I am also using a class library made from a different project using .net 4.7.2 which also references/uses the Windows.Devices.Bluetooth library and thats when im getting this error:
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'BluetoothLEDevice' is defined in an assembly
that is not referenced. You must add a reference to assembly 'Windows,
Version=255.255.255.255, Culture=neutral, PublicKeyToken=null,
ContentType=WindowsRuntime'. 128 Active
So i can access the library directly but not through the dll. Maybe its a problem that the dll uses a different framework?
Does anyone know how to solve this?
The solution to this was to upgrade the class library project .net 5 so that both projects are using the same framework.

xamarin intent extension with netstandard cause MT2001 error

I'm trying to add siri intent to my application.
I've created intent extensions project, than created ios library project (kit project as in a documentation) which has reference to .netstandard project with shared logic (core).
The core project use MvvmCross and when i'm trying to build main application it cause to:
error MT2001: Could not link assemblies. Reason: Error while
processing references of 'Diabetto.iOS.Intents, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null'
With more detailed logs i've known a reason of this error:
Error while processing references of 'Diabetto.iOS.Intents' --->
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'MvvmCross, Version=6.4.1.0, Culture=neutral, PublicKeyToken=null'
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'MvvmCross, Version=6.4.1.0, Culture=neutral,
PublicKeyToken=null'
I've tried to add nuget reference to iOS class library, to iOS intent library (unsuccessful, got error
Failed to add reference. The package 'MvvmCross' tried to add a
framework reference to 'System.Drawing.Common.dll' which was not found
in the GAC
VS 2019 16.3.5, iOS project 13.1
To be clear, my project structure
and link to project
Solved this problem.
Explicit add nuget reference to System.Drawing.Common and MvvmCross.
Problem was in System.Drawing.Common, VS is trying to use GAC version. With nuget reference it use .net standard version.

"Type forwarded to assembly 'Windows version=255.255.255.255'" when trying to use Windows.System.UserProfile

I'm trying to use the Windows.System.UserProfile.LockScreen class from a UWP class library in Visual Studio 2017.
However, trying to reference this class causes a variety of errors regarding a Windows assembly reference for version 255.255.255.255. Since 255 is the maximum value for a byte, I'm assuming that's not a real version number.
The error says:
The type forwarder for 'Windows.System.UserProfile.LockScreen' in assembly 'Windows' causes a cycle.
The type name 'LockScreen' could not be found in the namespace 'Windows.System.UserProfile'. This type has been forwarded to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' Consider adding a reference to that assembly.
My project structure is:
My project is configured with minimum Windows 10 version 'November Update (10.0, build 10586)'.
How can I resolve this issue and use the LockScreen class?
It turns out that this type is actually part of the Desktop Extensions, so you have to add a reference to them in your UWP Class Library. Right-click the project, select Add, Reference... and in the dialog go to Universal Windows - Extensions. There check the box next to Windows Desktop Extensions for the UWP of the appropriate version the app is targeting.

Can't publish ASP.NET 5 with external library reference

I have included an external reference of Moneris library eSELECTplus_dotNet_API.dll to my ASP.NET 5 RC1 project. It wrapped it alright and I can build project and run it using Kestrel. But when I publish it from VS or command line I got following error:
The package ID 'eSELECTplus_dotNet_API' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'.
I tried to rename library to a better name to fit nuget specs and it worked so I can publish it. But now when I run my project I got runtime error saying following:
System.IO.FileNotFoundException : Could not load file or assembly 'eSELECTplus_dotNet_API, Version=2.5.3.0, Culture=neutral, PublicKeyToken=8cb9cd598f87e276' or one of its dependencies. The system cannot find the file specified.
Please advice.

Categories