Xamarin forms Add reference to Web service - c#

so I'm creating an app with Xamarin Forms Portable and I want to use a Web service that I hosted in Azure. As far as I know, I can't add a reference by right clicking on the Reference tab in the PCL project... So I wonder if anyone could provide me with a fairly simple and straight forward solution?

Need to change to Pcl profile 78.
Ok to do so... Right Click , properties on the PCL Project.
Uncheck Windows Phone 8.
Check Windows Phone Silverlight.
You are now using Profile78! Allowing you to add Silverlight WCF client :).
Wish this was documented better.
You can see what profile you are currently using by opening the proj file in notepad.
Happy Xamarining!

References can be added if your project targets does not connect windows. Right click the PCL project and change the targets, remove windows.

you can use application => "Service Reference Generator For .net Standard & Xamarin.Forms" from : https://files.fm/u/mduffseg
first read help in application

Related

How to fix Microsoft Store package validation error: You cannot submit pre-compiled .NET Native packages?

I'm developing a WPF application, I added a custom WinRT component (implemented in UWP) and I'm hosting this win10 component in the WPF app, via XamlHost. I followed every step of the documentation, my custom controls are implemented in a UWP app project instead of a UWP class library. The app runs well and the UWP components are displayed properly in the WPF application. I could create the app package, but when I uploaded to the Microsoft Store (the .msixupload file), the following error was thrown:
Package acceptance validation error: You cannot submit pre-compiled .NET Native packages. Please upload the Microsoft Store appxupload file and try again.
What they mean pre-compiled .NET Native packages?
I also checked the sample application, which contains a winrthost.dll for different architectures. However the documentation doesn't mention this, I also added to my UWP project and configured as it is in the sample app's .csproj file. I tried to remove this dll file, but the store still doesn't accept the build.
As I removed the reference to the UWP App project, the Store accepted my build. As I re-added the reference (without using any component from it), the Store rejected. So I think the problem is in the custom UWP app, but what could be a pre-compiled .NET Native package here?
Update:
I added a new empty UWP app project to the solution, just set up the XamlApplication and referenced it from the WPF application. The UWP component shows in the WPF (I added just a green rectangle), but when I tried to upload to the store, it displayed the same error message.
As the documentation says, also tried to create a UWP class library instead of the UWP app. Created the build and the store accepted... What is the difference?
The documentation says:
You can alternatively define the custom control in the UWP app project
you created in the previous section. However, these steps do this in a
separate class library project for illustrative purposes because this
is typically how custom controls are implemented for portability.
So, theoretically it would be possible to publish a WPF app with a custom WinRT component hosted in a UWP app, right? Then why the store doesn't accepts?
After one day of investigation, I found that the solution is just to add the UWP app as a reference to the Packaging project (not just to the WPF app).
As I added to the references, the Store accepted the build. More details here.

How to deploy your Xamarin iOS to the web as a progressive web application (PWA)

I am new to Xamarin and I have successfully created an application in Xamarin for iOS. What I need is a way for this application to be viewed in the browser as a PWA. I figured to learn xamarin because I thought that this was a useful resource.
I have looked in to ooui but I can't successfully attach my Xamarin project to ooui.
At the end of this project I will have a running PWA coded in c# for iOS in the browser.
A link to the Xamarin can be found here:
https://github.com/SunRhythms/iosslidingpuzzle/tree/master/iOSSlidingPuzzle-3
Welcome to Xamarin! Your github repo is set to Private in it's setting.
Gathering from your other question as well, it's clear that you are using Native Xamarin.iOS and not Xamarin.Forms. (They have several differences if you check this)
Presently, there is no way of porting your Xamarin.iOS project into a PWA that has been made public. If you do convert your project manually into a Xamarin.Forms project, you could potentially use Ooui to convert Xamarin Forms into high performance WebAssembly code.
It seems like you have a sliding puzzle game, so it would be cool if you do end up doing it! Share it with us and the rest of the Xamarin community

Visual studio 2015 can't add Service Reference

I know there are a lot of questions like this, but none of them solved my problem.
I have a Windows Phone project, with some associated projects. I need to create a new project with the service reference, but I can't add it.
I found a link where they said to install a component from Add Connected Service > find other services > WCF Services but it says that my project is not supported.
Which kind of project must I create? I have in the same solution a project which has the right-click > add service reference but I was not the creator and I don't know what kind of project it is.
PS:
- I can't right click > Add service reference, I tried it in both project name and reference name.
- I need a Windows Phone Stuff. I link what i mean with a picture:
PSS: The destination version of windows phone is not the reason. I tryed changing the WP8.0 into WP8.1 and I can still add the ref
Does anyone know which kind of project I have to add for being able to add service ref?
Thanks
Instead of using Service Reference would suggest you to switch to the Windows recommended REST API endpoints instead. As now Windows is focusing more on REST service consumption than adding service reference that was available earlier.
Sadly now Windows Phone Store apps in Windows Phone 8.1 do not support the System.ServiceModel namespace generated by the Add Service Reference menu. Hence they have removed the option Add Service Reference.
To be able to use it you will have to create a Silverlight application and use this Workaround of using a WCF service.
You can find a MSDN Forum discussion of the same.

How do I include a timer in a universal windows app with c#

I need a timer in my universal windows app. I have read that the only one available for universal windows apps is System.Windows.Threading.DispatcherTimer. In order to use this I manually added the WindowsBase.dll to my app's references in the solution explorer in visual studio. Now I get the following error:
Error 3 Cannot find type System.ComponentModel.TypeConverter in module System.dll. Game.Windows
The error goes away if I delete the WindowsBase reference. What am I doing wrong?
The assemblies you can add to a Universal app are listed in the Project + Add Reference, Assemblies, Framework list.
Yes, it is empty.
That was intentional.
Because you already have a reference to all possible .NET assemblies in a Universal app project. Using the Browse button is not a workaround. And causes the kind of misery you describe, WindowsBase has types that can only work in a WPF app. The kind that runs with the full .NET Framework you've got installed on a desktop. Not the kind that a user has on his phone, called .NETCore. It is small, phones are small.
You already have the Windows.UI.Xaml.DispatcherTimer available in a Universal app project, no need to add a reference.
I think the one that windows store apps use is located in Windows.UI.Xaml namespace
I have been using ThreadPoolTimer, in Windows.System.Threading.

How to use RestSharp Portable 3.0 in Xamarin?

I'm working on a mobile app with Xamarin and I need to use a librairy for webservices which works on Android, iOS and Windows phone !
I checked a long time on google, and I think the best one is RestSharp Portable 3.0.1.
First I launch Visual studio and I click on file - new - project - visual C# - Mobile APPS and then BLACK APP (Xamarin.forms Portable).
After this, I got a full project with :
1 - My project (HelloWorld here for example)
2 - My project.android
3 - My project.iOS
4 - My project.WinPhone
I click on the 1 and then I add the RestSharp Portable references via Nuget and it's okay.
Now, i'm trying to use it but I cannot find anything on google about it, I don't know if it's because it's a new version but I have nothing on it.
So the question is : WHat is the best using WebServices into Xamarin for a cross app ?
Thanks guys !
I use RestSharp with no issues.
Here is the component link.
And here is their website.
It doesn't say that the component supports windows phone but I'm sure you can port it.

Categories

Resources