How to build ServiceStack to use it with MonoDroid? - c#

I'm trying to use ServiceStack REST DTO and OrmLite with monoDroid.
But I can't fugure out how to build ServiceStack to use it.
By default I have error while deploing to mobile device:
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(464,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?

The problem here was that you were trying to use a ServiceStack DLL compiled against the full .NET profile from your Mono for Android application, which is destined to fail. In this particular case, it was failing because that DLL had a dependency on System.Configuration, which is not included in the Mono for Android profile. In order to use a library with your application, you should compile its source against the Mono for Android profile, which will verify that the profile supports it, and allow you to safely reference it from your application.
When trying to compile a Mono for Android version of an existing library, the easiest place to start is with the Silverlight build for it (if there is one). Since the Base Class Library exposed by Silverlight is very similar to that of Mono for Android, the set of files/compilation symbols generally lines up between them as well. I have an old post up here that talks about how to link files in from other projects in order to properly compile a class library.

Related

How would I implement this service/dll in a Unity project?

I'm using a service called JNBridge which is used to create proxies for Java files to be used in C#. The service works fine and I can easily create a C# solution in Visual Studio 2017 and call Java files from created proxies. I would like to use this in a Unity project however but I'm not sure how I would accomplish this.
In order to get this to work in Visual Studio 2017 I first create the proxies I want to use and build it into a dll. After that I create a console application and add the .dll as a reference (+ another .dll needed by the service). The service also needs to use an Application Configuration File and a non .NET .dll. These two files have to get copied to the build folder in order to run the application.
When I try recreating this in Unity I add the two .NET .dll files to the Assets folder and it seems to work since scripts autocomplete code from the .dlls. However in the Unity console I get a FileNotFoundException. I also have no idea how I would go about including the non .NET dll and the config file.
System.IO.FileNotFoundException: Could not load file or assembly 'DotNetToJavaProxies, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'DotNetToJavaProxies, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()
I'm not that familiar with Unity so I'm asking, can I accomplish this? Using the config file and the .dll, and fixing the error.
JNBridgePro does not support Unity, so it is unlikely that this would work, although I have to say that we have never tried it. Starting with the new version 10, JNBridgePro does support .NET Framework and also .NET Core 3.0 (on Windows and Linux). Perhaps one of those scenarios would work for you. If you have additional questions, please contact JNBridge support.

.Net (Xamarin) Shared library works in Android but not iOS

We have a solution with an Android project, and iOS project and a shared library. The shared library has RestSharp installed (v 106.3.1).
When we run the Android app it works fine, it uses the shared library, it uses RestSharp to connect to a server and get some info.
When we run the iOS app (it builds fine) it stops mid execution and gives us this error:
Unhandled Exception:
System.TypeLoadException: Could not load type of field 'MyLibrary.ItemManager+<>c__DisplayClass4_0:client' (0) due to: Could not load file or assembly 'RestSharp, Version=106.3.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. assembly:RestSharp, Version=106.3.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75 type: member:(null) signature: occurred
We've done some research and tried closing and opening VS, reinstalling RestSharp, check references, etc. But it works with the Android project so it would seem to be set up correctly.
Any help?
For Xamarin iOS projects you need to include the DLL's and/or Nuget packages in the iOS project itself, as the compiler does not perform those actions for you.

Using assembly redirection in UWP C#

Hi!
I'm getting a typeload exception, the assembly being loaded is targeting runtime version v2.0.50727, other assemblies targets v4.0.30319.
I've been reading about Assembly Redirection and I think it could solve this problem but I'm unsure how this would be applied in a UWP app as there is no app.config.
Any advice would be helpful!
System.TypeLoadException: 'Could not load type 'System.Net.Sockets.Socket' from assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.'
In UWP platform, it would be better to create a Universal Windows Class Library then add it as a reference into the UWP project. You can try to create a Universal Windows Class Library and add your code into it as the following image,
From Windows 10 Fall Creators Update(16299), UWP supports .Net Standard 2.0, you can also create a .NET Standard 2.0 Class Library in VS2017.
Last but not least, I think you should learn more about the relationship among .Net Framework, .Net standard and UWP, you can look into the following blogs to get a better understanding:
https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/
https://msdn.microsoft.com/en-us/magazine/mt814993.aspx

.NET Standard 1.4 Class Library in UWP app

I'm exploring the idea of using this product in a UWP app, and one approach I'm starting to look at is to port the available C# .NET wrapper the manufacturer made available on their website to a Class Library using .NET Standard 1.4.
https://www.usdigital.com/products/interfaces/pc/usb/USB4
I believe I've got it close where I can reference the library in my UWP app and it runs, but I keep running into issues like the one below. I've tried referencing NuGet packages for System.Threading.ThreadPool (v4.3.0) and NETStandard.Library (v1.6.1), but it doesn't work. I have verified that the ported class library still works for an existing .NET desktop app we've used it on.
Could not load file or assembly 'System.Threading.ThreadPool,
Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The system cannot find the file specified.
Edit1:
I've removed portions of code that reference System.Threading and it seems that was the least of my problems. UWP app now runs, however it's unable to read from the device. Verified it still works on the old .NET desktop app with the modification.
The class library has a bunch of [DllImport("USB4.dll")]. Is that not supported in .NET Standard 1.4?

Windows Universal App: Could not load file or assembly - The located assembly's manifest definition does not match the assembly reference

I'm trying out the new Windows Universal App and I can't get it working with a .net API necessary for the app. The API in question is for a software our company uses called Moraware.
I can build a C# Classic Desktop Windows Form App for .Net 4.6, reference the .dll and it works without a problem.
When I write a C# Universal App, it builds fine, but when I do anything with the API like Connection.GetJob(12345), I get the following error:
Could not load file or assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b743552344e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I tried adding System.Xml as a reference, but I get the error: A reference to System.XML.dll could not be added. This component is already automatically referenced by the build system.
I also added the Microsoft .NET Core Runtime Package for Windows, and the Windows Desktop Extensions for the UWP, but nothing changed.
Any ideas on how I can get this api working with a Universal Windows App?
I guess the referenced library is not a Portable Class Library and itselfs refers a full .Net Framework System.XML. This assembly is not available to the UWP loader or if also loaded not compatible with the .Net SDK distributed with UWP (.Net Core based).

Categories

Resources