Package tried to add reference to System.Runtime which was not found in the GAC - asp.net

ASP.NET 4.5.1 or 4.5.2
Updating Nuget package MicrosoftAspNet.Identity.EntityFramework from version 2.2.1 to version 3.0.0-rc1-final
I get the following error:
Failed to add reference. The package 'Microsoft.AspNet.Identity.EntityFramework' tried to add a framework reference to 'System.Runtime' which was not found in the GAC. This is possibly a bug in the package. Please contact the package
owners for assistance.

I had a similar issue with another package.
I "solved" it adding a manually reference to missed library, updating the package and then removing the reference added manually:
On your project go to References -> Add Reference... and then click on Browse...
On my installation (Windows 10), your file is located on: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll
Add, update and then remove.
I know, it is not a solution, but it will allow you continue working until get a real solution.

I had the same issue, but adding the MySQL package to my project.
The way that i solved was just very closely to the answer given by Sebastián Guerrero.
So i will be adding a manually reference to that missed library (system.runtime) and than installed the MySQL package and it works perfectly.
ATTENTION: I only unnistall the system.runtime package after installing the MySQL.
References -> Add Reference... and then click on Browse...
On my installation (Windows 10), your file is located on:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll

I had the same issue when running Install-Package Microsoft.Azure.Management.Fluent on .NET framework 4.5.2
Solved the issue with the following steps:
Installed Microsoft.Rest.ClientRuntime latest version from Nuget.
After that, installed latest version of Microsoft.Azure.Management.Fluent from Nuget.

I had this problem when I opened the project after a while.
The problem was it was originally built with Microsoft.Net.Compilers.2.4.0 and I was on 3.3.1.
The project strangely added two required Imports to the .csproj file, one for the 2.4.0 compiler,and a duplicate for the 3.3.1 version. I just needed to:
Right click on the project file
Unload the project
Edit the csproj file
Remove the 2.4.0 references (was also a reference in an Error element)
Close file
Right click on project, reload file.
Rebuild All

Related

How to add SixLabor.ImageSharp in .net core project

Hey I want to resize images stored in a folder using .net core 3.1. The library I am trying to use is SixLabor.ImageSharp. I tried to install its latest version using nuget package manager and it was successfully installed and later on I added namespace SixLabor.Imagesharp in my .Cs file. but I am getting an error Namespace sixlabor.imagesharp not found. how can i use image sharp in my project. I read its documentation it was mentioned that Image sharp is available in Nuget package manager but its not working for me.
Please install the Nuget Package "SixLabor.ImageSharp" in the desired project. Once done, in your Startup.cs configure it as mentioned on their getting started page https://docs.sixlabors.com/articles/imagesharp.web/gettingstarted.html

Brand new Monodevelop installation can't restore packages

I'm trying to use MonoDevelop in order to work with .NET Core. In a brand new Linux Mint 20.1 machine, I installed MonoDevelop 7.8.4, and opened a project that I'm working on, and the IDE complained imediatelly:
Getting restore information for solution /home/REDACTED/project.sln
ApplicationName='/usr/bin/mono64', CommandLine='"/usr/lib/mono/msbuild/15.0/bin/MSBuild.dll" "/tmp/NuGetScratch/3r24uwj4.84i.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:RestoreBuildInParallel="False" /p:RestoreUseSkipNonexistentTargets="False"', CurrentDirectory='/home/REDACTED', Native error= Cannot find the specified file
The file /usr/bin/mono64 does not exist. Anyone knows how I can fix this?
UPDATE
When I try tobuild the project, it fails with the followiing error:
Error: NuGet packages need to be restored before building. NuGet MSBuild targets are missing and are needed for building. The NuGet MSBuild targets are generated when the NuGet packages are restored. (My.App)
This seems to be connected with the previous error message.
I have just installed Ubuntu and for anyone interested I found a solution.
In /usr/bin, make a mono64 symlink to mono-sgen. mono is already a symlink to that.
I will investigate the other tools suggested.

The term 'Add-migration' is not recognized - VS2017 and EntityFrameworkCore

I am posting this question just in case the solution I found would help someone else out. While working in Visual Studio 2017 rc4 each time I tried to run the Add-Migration command in the Package Manager console I get the following error:
The term 'Add-migration' is not recognized...
The solution that worked for me after trying a whole raft of other solutions posted, was to:
right click on my project
select Manage Nuget Packages
select the browse tab
thick Include prerelease check box
install the Microsoft.EntityFrameworkCore.Tools
N.b that aspnetcore project in visual studio 2017 do not seem to have the project.json file.
You just need to initialize the powershell module. I believe this is a bug, but it's pretty easy to work around. All you need to do is find the init.ps1 file and dot source it.
Just type this into the package manager console:
C:\Users\YourUserAccount\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.1.0-preview4-final\tools\init.ps1
Now the version might be different for you, depending on which one you have installed. Make sure you dot source the same version that is in your project.
Hi There
This is almost an normal problem in Microsoft, and they pointing out the same solution:
Microsoft Docs - Getting Started with EF Core on ASP.NET Core with a New database
For me above dosn't solve my problem, but this line first does:
PM> Install-Package Microsoft.EntityFrameworkCore.Tools
PM> add-migration InitialCreate
/Cheers, Jan
Make sure that the Microsoft.EntityFrameworkCore.Tools package is installed. If it's not, then add it from NuGet or simply type the following in the Package Manager Console:
Install-Package Microsoft.EntityFrameworkCore.Tools
Installing the above package worked for me.
If your are using VS 2019 and Dot.net core version 3.1
Just install the : Microsoft.EntityFrameworkCore.Tools from Manage NuGet Packages
this solved my problem.
I have had the same problem with a project created with VS2017 version 15.9.4 and .Net Core 2.1.
I have fixed it by adding Microsoft.EntityFrameworkCore.Tools to dependences of my project.
On project select Manage Nuget Packages
Browse and Search Microsoft.EntityFrameworkCore.Tools
Install it on your project
Then you can open Package Manager Console and use commands :
Add-Migration
Drop-Database
Get-DbContext
Scaffold-DbContext
Script-Migrations
Update-Database
Regards
dcube
Download the latest .net Core 2.0 from the link below and it will fix your issue:
https://www.microsoft.com/net/core#windowscmd
I reinstalled package Microsoft.EntityFrameworkCore.Tools and issue got fixed for me.
It works for me.
Close all VIsual Studio instances.
Open VS.
Open Package Manager console, let it be initialized.
Now open the project and try Add-Migration.
For me, I had to copy the folder microsoft.entityframeworkcore.tools from
C:\Program Files\dotnet\sdk\NuGetFallbackFolder
To
C:\Users\<user>\.nuget\packages
You have to add this to your CSPROJ file. This will most likely be fixed when the Core 2.0 is released. This stems from an issue where you can not install this package Microsoft.EntityFrameworkCore.Tools.DotNet using the NUGET tools due to version requirements.
Then using CMD/PowerTools in the project directory you can issue the following commands:
dotnet ef migrations add InitialCreate
dotnet ef database update
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
</ItemGroup>
I had the issue with VS2019 Enterprise on a .NET MVC 5 project with EF6.3.0. I was pulling my hair out and crushed for time. I was trying everything. In desperation, here's what I did that finally worked, FWIW.
Open VS2019
Let it completely finish all background processes on load (lower
left-hand corner animated icon)
Close Package Manager Console
Right-click Project, select "Manage NuGet Packages"
Check "Include Pre-Release"
Choose "Browse" Tab Update EntityFramework to V6.4.0-preview2-19525-03
Close VS2019 Open VS2019 Select from Menu:
Tools > Nuget Package Manager > Package Manager Console which opens
the PM console
At THIS point, FINALLY, add-migration "MyReferencePoint" worked!
Hope this helps someone.
we get the same error when "add-migration", i try one solution which is update Package Manager by using follow step
In Visual Studio, from the "Tools" menu choose the "Extensions and Updates" option.
From the dialog that appears, expand the "Updates" node from the tree at the left side.
Select the "Visual Studio Gallery" option from the tree.
Finally, look for the Package Manager update in the list of updates at the right side of the dialog and click the "Update" button beside it.
it is approx 5 - 10 MB update, after update complete try Get-Help Add-Migration

NuGet packages not found after sync from GitHub

We (me and three other people) will make an ASP.NET MVC application and use GitHub for version control. We've added some NuGet packages like Unity.MVC5.
Person one has commit and sync the project to the master branch. He's got no problems. The other three people sync the branch but they got problems with the NuGet libaries. See errors below:
Error: This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.
Error: Metadata file D:\...\MarkeOnlineWebsite\MarkeOnline.Website\bin\MarkeOnline.Website.dll could not be found
Warning: The referenced component ... could not be found.
Update: I've also added this .gitignore file.
How could we solve this problem?

can't install google map control in ASP with NuGet

When I click install in the NuGet packages manager the screen looks like it flashes for a split second and does nothing, if I look in installed packages there are no packages installed. However it does add this line to the web.config file
<add tagPrefix="artem" namespace="Artem.Google.UI" assembly="Artem.Google" />
since the package is not installed properly I can't use the artem map control. I have created a new project and installed it fine so it is something in my current project that I need to change that is not allowing me to get it installed. The things I have done so far:
1. Browsed to the packages file in my project and deleted the GoogleMapControl.6.1 folder.
2. Removed the line from the web.config folder.
3. Removed the reference to Artem.Google in my project.
4. Cleared package cache which had google maps file in it.- Manage Nuget Packages - Settings - PackageManager - General - Clear Package Cache.
Then tried to reinstall from manage Nuget Packages - Google Map Control.
Now I click install and it looks like it installs ok has a green tick next to it, then I try and add a :
<div>
<artem:GoogleMap ID="GoogleMap2" runat="server"></artem:GoogleMap>
</div>
GoogleMap is not a know element, no Artem tools in the toolbox and if I go to the package manager and click on installed packages, there is nothing there. So it is not installing fully somehow. Any ideas?
These are the steps I followed to fix the problem
Browse to the packages file in the project and delete the GoogleMapControl.6.1 folder.
Remove the line from the web.config folder.
Remove the reference to Artem.Google in the project.
Clear package cache which has google maps file in it.- Manage Nuget Packages - Settings - PackageManager - General - Clear Package Cache.
Delete the packages.config file
install with the Package Manager Console run:
PM> Install-Package GoogleMapControl -Version 6.1.0
Add <%# Register assembly="Artem.Google" namespace="Artem.Google.UI" tagprefix="artem" %> to top of asp page where the maps will be used.
Add to body of this page.

Resources