Is there a RestSharp implementation that works with Portable Class Libraries? - restsharp

When I try to add RestSharp to a portable class library project using nuget, I get the following:
Could not install package 'RestSharp 104.1'. You are trying to install
this package into a project that targets
'.NETPortable,Version=v4.0,Profile=Profile104', 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 assume then it is not supported? If that be the case anyone have any suggestions on how to get this to work?

Another interesting option is Flurl
Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library.
Code snippet:
var result = await "https://api.mysite.com"
.AppendPathSegment("person")
.SetQueryParams(new { a = 1, b = 2 })
.WithOAuthBearerToken("my_oauth_token")
.PostJsonAsync(new { first_name = "Frank", last_name = "Underwood" })
.ReceiveJson<T>();

You have a portable RestSharp working at:
https://github.com/Geodan/geoserver-csharp/tree/master/RestSharp
It seems it's working well... It uses Json.net portable version too

You may try RestSharp.Portable. This is a library which offers an API very similar to RestSharp.

You may also want to look at PortableRest. Again, provides similar capabilities (and adheres closely to the API style) to RestSharp for .NET 4.5, Silverlight 5, Windows Phone 8.x, and Windows 8.x, as well as iOS and Android through Xamarin.

Related

Kotlin Native libcurl example on Windows

I'm trying to learn how Kotlin Native works with this tutorial from JetBrains: https://kotlinlang.org/docs/tutorials/native/interop-with-c.html
But these tutorials are only fro macOS and Linux. Sometimes i use a windows computer and i want to know how it works there.
How can i add the libcurl library in windows and how can i add it to the libcurl.def file?
It isn't explained anywhere.
You need to install MSYS2, then in MSYS2 console install libcurl:
$ pacman -S mingw-w64-x86_64-curl
See https://github.com/JetBrains/kotlin-native/pull/1499
A more detailed step-by-step explanation on how to use dynamically built libcurl (aka DLL) with Kotlin/Native.
https://jonnyzzz.com/blog/2018/10/29/kn-libcurl-windows/
I do not think it is covered somewhere right now. The idea is still the same, and you should be able to make it work. The first step is to download and build libcurl locally from https://curl.haxx.se/libcurl/. There are instructions and documentation on how to build it. I do recommend to pick the Windows own implementation for SSL.
Once you are done with building you will have both the includes and the library. Note, on Windows, you will always have a static library. Even if you build curl as a dynamic library (DLL), you will have a generated static library that you use for linking. DLL is easier to build and use. A true static library is better because you will have no dependencies in your Kotlin/Native program binary. At that point, the tutorial instructions should work.
For Windows, if you need only basic HTTP communication, you can also try WinINet API which is a part of Windows and so no dependency is necessary. No hassle with the libcurl library.
See my example of how to use WinInet API with Kotlin MPP: https://github.com/localazy/kotlin-mpp-wininet
For macOS and Linux, instead of going through the hassle with libcurl manually, just use ktor clients: https://ktor.io/clients/index.html
I'm studying Kotlin too and it took many hours until I realize how to handle def file, includes and static library.
I made an example of how to use static library (curl with gzip and SSL support compiled with mingw) on kotlin-native. This way you dont need to dll files to be supplied with your app
https://github.com/carlosrafp/Libcurl-Kotlin-Native-standalone
On libcurl.def file you can see:
headers = curl/curl.h // path to curl header
libraryPaths = src/nativeInterop/cinterop // path to your static library
staticLibraries = libcurl.a // the static library
linkerOpts.mingw = -lws2_32 -lwldap32 // linking dependences
I based on the nice post of jonnyzzz:
https://jonnyzzz.com/blog/2018/10/29/kn-libcurl-windows/

Ninject and MonoDroid

Anyone had any luck getting Ninject to work on MonoDroid? i've tried the 2.0 and 4.0 mono builds from their website and also tried the .net versions.
With the Mono builds i'm getting a MissingMethodException in the instantiation of my StandardKernel
I am experimenting with Ninject on a combined WP7/Monotouch/Mono for Android project and Ninject works surprisingly good.
I used the latest sources, which contain a project file Ninject.WP7.csproj which seems to be outdated. It contains a lot of DefineConstants. I created new WP7/Monotouch/Mono for Android solutions with these constants and everything compiled and works!
Constants used:
SILVERLIGHT,SILVERLIGHT_40,NO_LCG,NO_ASSEMBLY_SCANNING,NO_WEB,NO_PARTIAL_TRUST,NO_SKIP_VISIBILITY,NO_EXCEPTION_SERIALIZATION,NO_DEBUG_SYMBOLS
not sure if they are all needed, but the SILVERLIGHT one is important because Monotouch/Mono for Android implement a large part of the Silverlight api.
Of course you cannot create Android Activities with Ninject. I use it mainly for constructor injection, to create .Net objects like a ViewManager, view models using a repository, etc., the usual things you do with dependency injection.
I haven't tried to get Ninject working, but I'd be very surprised if it just worked out of the box. If there's a Silverlight build of Ninject you may have more luck with that, but there are no guarantees. The "best" way to get support for it in Mono for Android would be to build the code against the Mono for Android profile as a class library.
That said, there are other options out there for doing service location in your apps. I have a blog post up here that talks about using TinyIoC and Funq for service location.

How should one deal with library clashes in Application Servers?

Third-party libraries are often included by the appliation server you are deploying to and class with the ones included by your application. So far I have dealt with this in the simplest and hackiest way possible: removing the libraries on the app server.
In our case it is ok, noone is relying on the app server to provide them with any libraries. But if I were running my app along with lots of other peoples app, which again might depend on the libraries included by the application server, this would not be a solution.
How is this supposed to be solved (cleanly)? How are you doing it?
An example of a problem might be this:
you build an jax-rs application using cxf, hibernate and jackson, and deploy to glassfish 2.1.1. glassfish supplies the asm 3.1 library, but this causes clashes with hibernate using an incompatible 1.5 version. similarly the application needs jackson 1.8.2 (due to a bug fix), but glassfish 2.1.1 ships with version 0.9. BOOM. Any way of fixing this other than simply removing offending libraries?
consider using :
asadmin deploy --libraries ...

DNP3 with VB.Net

I am looking for a good DNP3 library for .NET/VB applications.
Any recommendations?
Thanks,
The open-dnp3 project has recently added .NET bindings:
code.google.com/p/dnp3
Automatak maintains a fork of the opendnp3 library with .NET bindings:
http://automatak.com/opendnp3/
We have heard from users that opendnp3 significantly outperforms the TMW library for large master integrations.
Opendnp3 is Apache-licensed (free-to-use), but commercial support is available if you get stuck.
All I could find with a Google search was Trianble MicroWorks' .NET Protocol Components.
It looks like they're not exactly on top of the latest technology (it lists itself as .NET framework 2.0 compatible), but I wasn't able to find anything else that looked terribly promising.
I've managed to build the Automatak version of this library:
https://github.com/automatak/dnp3
and use the .NET bindings with C#, though they would work equally well with VB.
OpenDNP3 from automak is available in Nuget, but you should install 32bit openssl application to able to load it.It installs two required .dll files.

Are XmlMtomReader and XmlMtomWriter fully implemented in Mono project?

I'm working on a cross-platform solution currently. The solution uses XmlMtomReader and XmlMtomWriter from .NET framework 3.0.
Now i need to know if these two classes (and all the nessasary infrastructure around them) are fully supported in Mono project from the porting-it-to-linux point of view. :)
You can check it on the mono status:
http://go-mono.com/status/
You can also check your code using the mono migration analyser
http://www.mono-project.com/MoMA
I checked they are currently not implemented
The APIs are available on the current Mono 2.6 preview, but they are not available on the 2.4 release (the current official release).