Why can't my PCL use System.Runtime? - c#

I have a PCL that targets the following platforms:
.NET Framework 4.5
Windows 8
Windows Phone 8.1
I need to add a reference to System.Runtime because I want to use another package that depends on it. From what I can see, version 4.0.0 appears to include the target platforms mentioned above. However, when I try installing it via NuGet, I get this stack trace:
PM> Install-Package System.Runtime -Version 4.0.0
# ...
Install failed. Rolling back...
Package 'System.Runtime 4.0.0' does not exist in project 'PclDummy'
Package 'System.Runtime 4.0.0' does not exist in folder 'C:\Users\James\Documents\Visual Studio 2015\Projects\PclDummy\packages'
Install-Package : Could not install package 'System.Runtime 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', 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.
Why does this happen if System.Runtime supports all of the platforms my PCL does?

that targets '.NETPortable,Version=v4.5,Profile=Profile111'
Be sure to distinguish between reference assemblies and runtime assemblies. To get your PCL project compiled, you only need reference assemblies. And you already have one for System.Runtime, it is located in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile111 directory on your machine. It is already referenced in your project so the package was correctly rejected.
These kind of crazy "but everybody already has this" Nuget packages come from the CoreCLR project. It is evolving rapidly right now with beta versions released at a very high rate. Which is one of the targets supported by Profile111, it supports an ASP.NET Core 5.0 target. Not one you listed in your question so you probably don't need it at all. But if you would then it would be that project that downloads this Nuget package. Which is entirely automatic, you don't ask for the packages explicitly.
Just stop trying to get it installed.

it seems that System.Runtime is not completely supported in version 4.5.
you can check it in the profile folder in following path:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile111
there is a list of supported assemblies and namespaces.

Related

How do I install System.Drawing.Common in a project that uses '.NETFramework,Version=v4.5.2'?

I am trying to write some unit tests in C# in a '.NETFramework,Version=v4.5.2' application but all tests give the next error:
'System.IO.FileNotFoundException : Could not load file or assembly
'System.Drawing.Common, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file
specified.'
When I try to install System.Drawing.Common I get the next error from the NuGet package:
Could not install package 'System.Drawing.Common 4.5.1'. You are trying to install this package into a project that targets
'.NETFramework,Version=v4.5.2', 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 cannot change the application version or the framework (.NET Core 2.1) and any other trick I found online did not work (or generated more errors).
Help?
in NuGet put this line :
Install-Package System.Drawing.Common -Version 4.5.2
in .NET CLI put :
dotnet add package System.Drawing.Common --version 4.5.2
in Paket CLI put :
paket add System.Drawing.Common --version 4.5.2
Had the same problem. I have cloned solution https://github.com/barnhill/barcodelib . It has two projects: library project targets .Net Standard 2.0 and refers to System.Drawings.Common. Example project depends on library and has reference to System.Drawings.Common. Example project was not compiling due to same error.
My solution was just to remove reference to System.Drawings.Common in nuget packages and readd it (rclick on Example project > Manage nuget packages > Browse Installed, remove the System.Drawings.Common package, and then add it back), unload project and then reload it again
Helped for me.
I managed to solve it by restarting Visual Studio, changing the framework to 4.6.1 (which I could not do before) and adding the reference.
OP's solution migrated from the question to an answer.
you could try to use one of the libs described in here instead https://devblogs.microsoft.com/dotnet/net-core-image-processing/
you could try to use https://www.nuget.org/packages/CoreCompat.System.Drawing/ as well and maybe try to change your app framework to .net standard 2.0?
This is kind of bizarre but it worked dramatically so I'm going to mention it. I built a small vs 2017 ent console project that was supposed to read an oracle database. When I started to run it I got the System.Drawing.Common error mentioned above. It seemed stupid because I wasn't really doing anything having to do with Drawing at all. In Manage Nuget Packages I deleted the Oracle.ManagedDataAccess driver and added the Oracle.ManagedDataAccess.Core and the System.Drawing.Common error went away and I was able to read my oracle database. So I'm suggesting that with NuGet you may be picking up some things you really don't need and if you have any choice for your NuGet packages, try different ones. This also may be some foible with how my organization managed nuget for Visual Studio 2017 enterprise.

'System.Web.Mvc.VirtualPathProviderViewEngine' is defined in an assembly that is not referenced

The complete error is "'System.Web.Mvc.VirtualPathProviderViewEngine' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'"
I have an Asp.Net Mvc 4 application build in Visual Studio 2010 that does not build on one machine but builds on another machine without issue. Through the tips System.web.mvc missing I discoverd that the machine that builds does indeed have MVC 3 version 3.0.50813.0 and the machine that does not build has MVC 3 version 3.0.20105.0 so I uninstalled MVC 4 and MVC 3 and attempted every combination of uninstall and reinstall between downloaded installers and the web platform installer but the problem machine still gets the older version. I decide that I will just attempt to fix the project by upgrading the NuGet package for the one project using the suggestion from the question
Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1
at which point it the following error with the NuGet package Manager
"Install-Package : The schema version of 'Microsoft.AspNet.Mvc' is incompatible with version 2.0.30625.9003 of NuGet. Please upgrade NuGet to the latest version" In attempting to fix that I find this Nuget versioning issue with package restore
I performed the answer from there and got the same error when attempting to install the NuGet package, which makes sense because it is looking for an older version of NuGet.
I also looked at this MS14-059 but my project does not even reference the MVC 3 dll so the manual update option is out and I have tried the NuGet package.
My question is
Does anyone know where I can find an installation of the MVC 3 framework for version 3.0.50813.0
OR
How I can get the NuGet package to install in my solution.

Cannot update nuget package (PCL)

I'm getting this error when using maps in Android:
System.MissingMethodEsception: Method
'Xamarin.Forms.maps.Android.MapRenderer.OnCameraChange' not found.
And I've read that you can update the nugetpackage to fix the issue. However, I cannot install it due to this:
Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', 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.
The updates of packages installs just find in iOS and Android but not for PCL. I've tried to remove all the packages and then tried to add TK.Customs nuget package but this same issue.
Also tried to install it on a fresh project and that installed just fine. Just cant get it to install on my old project.
Here is the whole error message when trying to update package:
Attempting to gather dependency information for package 'TK.CustomMap.2.0.1' with respect to project 'Vernamo', targeting '.NETPortable,Version=v4.5,Profile=Profile78'
GET https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json 175ms
Total number of results gathered : 29
Gathering dependency information took 232 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 204.03 ms
Attempting to resolve dependencies for package 'TK.CustomMap.2.0.1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'TK.CustomMap.2.0.1'
Resolved actions to install package 'TK.CustomMap.2.0.1'
Found package 'TK.CustomMap 2.0.1' in '/Users/holger/Downloads/Vernamo/packages'.
For adding package 'TK.CustomMap.2.0.1' to project 'Vernamo' that targets 'portable45-net45+win8+wp8'.
Install failed. Rolling back...
Package 'TK.CustomMap.2.0.1' does not exist in project 'Vernamo'
Executing nuget actions took 52 ms
Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', 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.
The pre-release version (at least pre2) of TK.CustomMap supported all platforms (see here), anyway, as of pre3 (see here), obviously the support for all platforms was dropped in favor of .NET Standard (1.1 in this case).
The profile you are using in your PCL does not seem to be compatible with .NET Standard 1.1, hence NuGet fails to add the reference. You may try to switch to another profile (.NET 4.5.1 for example), but I don't know if that would help. Another option would be to migrate your projects to .NET Standard. It's kind of a stupid, repetetive task, but it's possible.

Cannot update Microsoft.Extensions.Logging to (2.0) Mono Develop 6.1.4

My packages in my project indicated there was a version update to 2.0 for:
Microsoft.Extensions.Logging
NETStandard.Library
Microsoft.NETCore.Platforms
The only one I cannot get to update is Microsoft.Extensions.Logging
The Error I get is this:
Package 'Microsoft.Extensions.Logging 2.0.0' does not exist in folder '/home/MyUser/UpdatedPon/pon/sbmanager/packages'
Could not install package 'Microsoft.Extensions.Logging 2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', 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 have been searching the internet the past few days looking for a solution, but I have not found one as of yet.
Has any one ran into this issue, I am running MonoDevelop 6.1.4
and my MONO version is 5.2.0.215.
Lastly this is a WebForms application.
The Microsoft.Extensions.Logging 2.0.0 NuGet packages has assemblies for .NET Standard 2.0.
A more recent version of NuGet is required for .NET Standard 2.0 to be recognised as a target framework. So you would need to use MonoDevelop 7.1 for this to work. Also your project would need to target .NET 4.6.1 to be able to install the NuGet package.
Alternatively you could try installing the older version Microsoft.Extensions.Logging 1.1.2 which contains .NET Standard 1.1 assemblies which should be recognised by MonoDevelop 6.1.

Nuget - Installing a package which depends on a library with a higher version than my project's reference

I'm trying to install a nuget package that depends on Newtonsoft.Json version 8.0.2. However, my project references a version 4.5.0 and I get a File Not Found exception when I run my tests. Can I get this to work without upgrading my project reference?

Categories