I included Refit into a PCL project and I keep receiving this error when I use the RestService.For method:
System.NotImplementedException: You've somehow included the PCL version of Refit in your app. You need to use the platform-specific version!
I used the Xamarin PCL project template. Here are my PCL setting:
.NET Framework 4.5
ASP.NET Core 1.0
Windows 8
Windows Phone 8.1
Xamarin.Android
Xamarin.iOS
Xamarin.iOS (Classic)
I have tried Refit versions 2.3, 2.4, and 2.4.1. Any ideas why this is not working? I'm assuming the PCL profile is incorrect but I do not know the correct profile.
Have you added refit to your platform specific application projects?
Yes, they're in the solution. So far I've only tested Android because I'm stuck at this error.
You have to add it your test project. If you´re using PCLs then test
project could a non-platform specific project (ex a .Net 4.5).
But using android/ios test project you should add refit to them as well
Hope i made my self clear.
On Wed, 20 Jul 2016 at 09:21 Josh Wood [email protected] wrote:
Yes, they're in the solution. So far I've only tested Android because I'm
stuck at this error.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/paulcbetts/refit/issues/250#issuecomment-233933172,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGr-6gQ1zuLQ4xPIiA7PtxdsVNlJiAKfks5qXhKqgaJpZM4JQW0A
.
I don't have a test project included yet. I was just saying while testing the application as a user, not from a test project.
My bad I got mislead by "I only tested on android"
Make sure you install in the P.S projects as well(you've done that?), watch
package manager console and verify that there isn't an error when
installing.
On Wed, Jul 20, 2016 at 3:11 PM Josh Wood [email protected] wrote:
I don't have a test project included.
—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/paulcbetts/refit/issues/250#issuecomment-234033113,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGr-6gu30hBBAFHnpUNf3aly9V3gveEyks5qXmTQgaJpZM4JQW0A
.
I have included them and ensure they installed ok. I have used Refit in a Xamarin Shared project before with no issue. Is my problem that I'm using a Xamarin PCL rather than a Xamarin Shared project?
Not at all. In contrast, i´ve always used it with PCLs, the only occurred
once because i didn´t install Refit in the platform specific projects
On Wed, 20 Jul 2016 at 17:24 Josh Wood [email protected] wrote:
I have included them and ensure they installed ok. I have used Refit in a
Xamarin Shared project before with no issue. Is my problem that I'm using a
Xamarin PCL rather than a Xamarin Shared project?—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/paulcbetts/refit/issues/250#issuecomment-234070709,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGr-6sErtOijuh3yA_u0l8Dozsod6vkuks5qXoQAgaJpZM4JQW0A
.
Here is what I've found out. I was using Refit in a Xamarin Forms PCL project. I had a Droid PCL and an iOS PCL. I confirmed that the proper platforms of Refit were installed in the 3 PCLs. The Refit PCL breaks in the Xamarin Forms PCL because iOS and Android are rendered using the Xamarin Forms PCL. Since the Xamarin Forms PCL is targeting .NET and the platform PCLs are targeting their respective Refit platform DLLs, I receive the error above. So I figured I had two options, duplicate the Refit code in the Platform projects or switch to a Xamarin Forms Shared project.
As soon as I switched my code over to a Xamarin Forms Shared project, I no longer receive the error. This makes sense, but I hate the shared project. But, it is what it is, and everything is working now.
Amedalejo thanks for your help, I appreciate how quickly you were responding and trying to help.
just to clarify there´s no such thing as Droid/iOS PCL.
You should make sure you install Refit in the platform specific project
(Android and iOS not just the pcls) as well
_Portable Class Libraries_ (PCLs) is a subtype of _Class Libraries_
_Class Libraries_ can be portable i.e can be used in more than one
platform without recompiling - the platform coverage of PCL is define
by it´s client profile which specifies supports for all .net platforms,
.NetCore, MonoDroid, MonoTouch e.t.c or just a subset of them.
Class Libraries can also be platforms specific i.e they can be re-used
between different projects targeting the same platform without recompiling.
So don´t confuse your Android/iOS class libraries with Portable Class
Libraries, because those are not "portable"
Cheers
On Wed, 20 Jul 2016 at 21:25 Josh Wood [email protected] wrote:
Closed #250 https://github.com/paulcbetts/refit/issues/250.
—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/paulcbetts/refit/issues/250#event-729764888, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGr-6iR4la3Ib4Gc9jfimUfqEsSevWGHks5qXryIgaJpZM4JQW0A
.
I have tried refit in PCLs, ensured that refit was installed on xamarin platforms aswell.
I also tried to use a shared project (completely removed connection to any PCLs).
I have also tried different versions of refit.
Nothing has worked, ai very frustrating..
Also getting the same error, i have Refit in a PCL and included the nuget in the Android project as well but i still get the same error
I am also getting this error. I am clearly referencing the MonoAndroid version in my Android project, but I still get this error at runtime.
Please, stop writing "me too comments" on a closed issue. Make a new one describing your problem with enough detail to help you. Probably linking to this issue in it too.
The highest version I could install was 2.4.1 then it worked. Unfortunately there were changes in the newer versions that don't allow it to work with PCLs.
What PCL type are you trying to use? Some PCL types may be supported, others may not be. Refit 3 supports .NET Standard 1.1+, so you need to be using a compatible PCL profile.
See https://github.com/dotnet/docs/blob/master/docs/standard/net-standard.md#pcl-compatibility for the table.
I have built a PCL project using Visual Studio for Mac. My project is using PCL 4.6 - Profile44 but i get the same error after including the library in the Android project
How to fix this? Ive already added all refit package in every platform including the PCL. It's very frustrating. Please someone
This ended up being an issue with the project file for me. Needed to manually move some stuff around.
Most helpful comment
I have built a PCL project using Visual Studio for Mac. My project is using
PCL 4.6 - Profile44but i get the same error after including the library in the Android project