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
Related
I'm building a .NET 6.0 application that needs to use CORBA and IIOP to communicate with a remote server.
To achieve this, i'm using IIOP.NET, which depends on the deprecated Remoting API, and because of that i'm getting this exception when initializing the library:
System.TypeLoadException: 'Could not load type
'System.Runtime.Remoting.Channels.IChannelSender' from assembly
'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.'
Is there any way i can make the assembly load correctly in .NET 6?
I've tried to manually link the System.Runtime.Remoting dll in the application, but that doesn't seem to work.
Hi I have the following issue, I am using xamarin on a Mac and created a cross-platform app solution using native single view app with portable class library.
In the portable class library i added one reference to newtonsoft.json v4.0.3 but when i rebuild my project i get errors like the following:
Reference to type 'System.ComponentModel.ITypedList' claims it is defined assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found.
What should i do?
Thank you very much in advance
Version 4.0.3 of Newtonsoft.Json is only available for .NET (2.0, 3.5, 4.0), Windows Phone 7 (I think) and Silverlight 4. This version does not support portable class libraries.
Use NuGet to download the latest Newtonsoft.Json version, it should provide a number of PCL alternatives, in particular a Profile 328 assembly that can target practically all modern platforms including Xamarin iOS and Android.
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).
I am trying to rewrite a project into a Portable Class Library. But the problem is that it is using Async CTP, and I can't compile it as a library for WP and Windows Store App. If I don't include reference AsyncCtpLibrary.dll, compiler says that
The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)
If i include it, compiler still says the same errors and adds a warning:
The primary reference "AsyncCtpLibrary" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "AsyncCtpLibrary" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
How should I bear with that?
You can only currently use async/await in portable when targeting .NET 4.5 and Window Store apps. Outside of portable, you can use the Async Targeting Pack for .NET 4.0 and Silverlight 5.
In saying that though, we are working on an updated async targeting pack that adds support for async/await in portable when targeting Phone 7.5, Silverlight 5 and .NET 4.0, see: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2691068-support-async-in-portable-class-libraries. You will see this early October.
Update: We just release a beta of this: http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx.
Simple answer - AsyncCTP is not working in Visual Studio 2012 and cannot be used in any project. For .NET 4.0 and Silverlight 5 you can install Async Targeting Pack from NuGet that works in a similar fashion.
Async/await is in Portable Class Library supported only when targeting WinRT, .NET4.5 or Windows Phone 8 and even then the use is pretty limited. I can't go into more details here, because the Windows Phone 8 SDK is still under NDA.
For WP7.5 and VS2012 there is currently no way how to use async/await, but updated Async Targeting Pack for this platform should be available sometime.
Note also that AsyncCTP and Async Targeting Pack can't be used in Portable Class Libraries and it's unlikely it will change in the future. The result is in VS2010 you cannot use async/await in Portable Class Libraries.
You can try to use the AsyncBridge project instead of the AsyncCTP. I don't know if it will help. You'll have to compile in VS2012 to get this to work though (you can still target .NET4.0):
http://omermor.github.com/AsyncBridge/
http://www.simple-talk.com/blogs/2012/04/08/asyncbridge-async-on-net-4-0-using-vs11/
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.