WebMatrix: Using #FileUpload Helper - asp.net

I have the System.Web.Helpers.dll and .xml files in the Bin folder of my website solution, but VS 2010 complains about "The name 'FileUpload' does not exists in the current context" event though I use #using System.Web.Helpers;
#using System.Web.Helpers;
<td>#FileUpload.GetHtml(
initialNumberOfFiles: 1,
allowMoreFilesToBeAdded: false,
includeFormTag: false,
uploadText: "Upload"
)</td>
What is wrong here ?

Watch out... if your using mcv3 make sure you install microsoft-web-helper 1.15, if you dont specify version in package manager it will automatically install version 2.0 and mess everything up as only mvc4 is compatible with 2.0.
CORRECT COMMAND SHOULD BE:
Install-Package microsoft-web-helpers -Version 1.15

just go to packages.config in your project and remove
package id="Microsoft.AspNet.Web.Helpers.Mvc" version="2.0.20710.0" targetFramework="net40"
clean your project
later install nuGet Microsoft.AspNet.Web.Helpers.Mvc
that's it

FileUpload is not in System.Web.Helpers. It is in Microsoft.Web.Helpers, which you can get from the Package Manager. Look for ASP.NET Web Helpers Library.
Installation
Right click on the project and choose Add Library Package Reference, or use the Package Manager Console and type
Install-Package microsoft-web-helpers

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

How to completely remove a package from project/solution?

I made an ADO.NET Entity Data Model in my MVC project. When I did this the EntityFramework package was automatically downloaded and installed into my project via the NuGet package manager.
How do I completely remove this ADO.NET Entity Data Model and its related EntityFramework from my project?
(I am working in Visual Studio Community)
You can use the following command line in the Package Manager Console:
Get-Project -All | Uninstall-Package <package name>
If this package have dependencies, you can add option -RemoveDependencies in above command line.
Or you can manually do it through the VS GUI,
Right-click your solution > Manage NuGet Packages for Solution..., switch to the Install tab, select the package which you want to uninstall, then you can check the first checkbox, all the check boxes would be selected, click the uninstall button:

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

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

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

Web API cannot resolve symbol Http in System.Web.Http, what is missing?

I have a webforms project.
I use nuget to install web API by running Install-Package WebApi.All
I create a class
public class CartController : System.Web.Http.ApiController
but it cannot resolve symbol Http in System.Web.Http, what dependency am I missing?
The name of the package for the ASP.NET Web API isn't "WebApi.All". The package for the ASP.NET Web API (Beta) is "AspNetWebApi". Try running the following instead:
Install-Package AspNetWebApi
Try using it with exact keyword from the package manager console. This is include the dependencies WebApi.Enhancements, WebApi.OData.
Install-Package WebApi.All -Version 0.6.0
For more information checkout NuGet WebApi.All 0.6.0
Another way is to use "NuGet Package Manager".
You can simply use "NuGet Package Manager" by right clicking on Project from Solution explorer, and search "Web API" term. Install it from there.

Resources