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.
Related
I try to be as detailed as possible in explaining our situation, premising that we made several attempts in relation to other similar situations found on stackoverflow. Specifically, we have a project consisting of many libraries in c# that has been updated from net 4.7 to asp.netcore 6.0. Within the project there is also a library of classes in c++. This library generates a dll that is used within one of the projects c#. The project in c++ has not been updated, but we simply went to vary the target framework from net 4.7 to netcore 6.0 (and also we changed clr to clr:netcore) as explained in the Microsost guide for porting hybrid projects in C# and C++. All the project builds correctly but when the debugging of the webapp in C# referencing the dll in C++ I get the following error:
System.BadImageFormatException: 'Could not load file or assembly 'Tradante.MT4.Wrapper, Version=1.0.8369.22669, Culture=neutral, PublicKeyToken=null'. Format of the executable (.exe) or library (.dll) is invalid.'
Navigating through various issues similar to our case, we seemed to understand that the incompatibility problem could be related to having a project at x64 and another at x86. We tried to vary all possible combinations but the error remains the same. But we noticed something strange: we forced the build to x64 of the webapp in C# but in the compilation output (which we see as enabled debugging of the native code) we find the name of the webapp followed by (Win32) as if the machine continues to build at x86. I don’t know if this information can help you.
I am working on a UWP application and I'm trying to call a library which uses Microsoft.IdentityModel.Clients.ActiveDirectory but it keeps throwing the following exception:
Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.17.2.31801, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I've tried updating the version to 5.2.6 but to no avail. I've also tried installing the Microsoft.IdentityModel.Clients.ActiveDirectory NuGet package directly into the UWP project, yet again to no avail.
I'm thinking this package is just not compatible with UWP? Because it works fine in a .NET Core or Framework console app. Is there a way I can shim it or force compatibility?
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.
I'm trying to create a Xamarin.Forms PCL client for SignalR. Every tutorial I found it's how to add SignalR to either Xamarin.Android or Xamarin.iOS. How can I add SignalR to Xamarin.Forms project?
Should I create an separate PCL, call it "Proxy" and then just use this PCL in Xamarin.iOS, Android and Windows Mobile projects?
If 1), should I add SignalR also in every project (besides PCL, where I'm really using it)?
Should I add to the PCL created by default, while creating Xamarin.Forms solution?
Thanks for help,
Here's the problem I'm getting:
I have a fully working Xamarin.Forms PCL project. I removed all windows stuff though. I just left PCL, iOS and Android projects. It works! I added CocosSharp only, but don't use it. Plain, empty, never touched Xamarin.Forms. Then I've added SingalR to PCL project. Complied, run - works! BUT when I add JUST this line:
var connection = new HubConnection("http://localhost:52128");
it doesn't even compile. I'm getting errors:
Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Perhaps it doesn't exist in the Mono for Android profile
I'm totally lost.
I've tried:
Installing nuget just on the PCL - error
Installing on every project - error
Creating new PCL, implementing that line there, adding it as a reference to the main PCL. Calling a method from the second PCL - error.
I met the same error as you did, it seems that when installing SignalRMicrosoft.AspNet.SignalR.Client package, the dependency packages cannot be automatically installed, the references got somehow corrupted.
To solve this issue, you can manually install those packages.
Install the following three Packages separately from Nuget:
SignalRMicrosoft.AspNet.SignalR.Client.
Newtonsoft.Json.
Microsoft.Net.Http.
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.