CssRewriteUrlTransform missing in System.Web.Optimization - asp.net

I'm trying to use CssRewriteUrlTransform but am having a problem referencing it.
I updated to the latest Microsoft.AspNet.Web.Optimization using package manager:
update-Package Microsoft.AspNet.Web.Optimization -reinstall
And can now see System.Web.Optimization v4.0.30319 referenced in my project.
However I'm still getting
Error 19 The type or namespace name 'CssRewriteUrlTransform' could not
be found (are you missing a using directive or an assembly
reference?)
Is there something else I'm missing?
(I've got using System.Web.Optimization;)
VS Cannot 'resolve' the issue.

Related

I have Installed Newtonsoft.Json from manage Nuget packages in Visual studio yet I get The type or namespace name 'Newtonsoft' could not be found

I have downloaded a tutorial file in which the tutor is explaing how to use Moralis to connect a wallet to a Unity game. However in many of the scripts it needs to use Newtonesoft.Json which apparently it can't.
I have already installed Newtonsoft.Json using NuGet package manager in Visual studio both in version 2022 and 2019. But yet I get this error.
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp D:\work\UNITY\Moralis test2\Moralis test2\Assets\MoralisWeb3ApiSdk\Moralis\Moralis.Web3Api.Core\Models\NftTransfer.cs 6 Active
enter image description here

.net core 2.1 can't reference automapper in startup.cs

In my nugent panel, I installed
AutoMapper v7.0.1
AutoMapper.extensions.microsoft.dependencyinjection v5.0.1
In my Startup.cs,
I added
Services.AddAutoMapper();
but the compiler gives
Severity Code Description Project File Line Suppression State
Error CS1061 'IServiceCollection' does not contain a definition for 'AddAutoMapper' and no accessible extension method 'AddAutoMapper' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) OPEApiService J:\Projects\OPEApiService\OPEApiService\Startup.cs 58 Active
I tried clean, rebuild, close and reopen VS.
Any help is appreciated.
Thanks
This could be a compatibility issue between the two packages.
If you have both the AutoMapper and AutoMapper.extensions.microsoft.dependencyinjection packages installed, remove them and add only the AutoMapper.extensions.microsoft.dependencyinjection. It has a dependency on the AutoMapper package.
I had this same issue and was able to resolve it.
You missed the restore step. From the root directory where the solution file exists, run following command:
dotnet clean
dotnet restore
dotnet build
Build error I received after including the services.AddAutoMapper();
Then after executing the series of command, got it running.
You need to add a reference to :
$ AutoMapper.Extensions.Microsoft.DependencyInjection
Search it using NuGet Packages Manager and install it.

`ExceptionHandling` not found?

I'm referencing System.Web.Http.dll, full path:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Http.dll
However, I'm getting a compile exception saying that it can't find ExceptionHandling in the System.Web.Http namespace.
The type or namespace name 'ExceptionHandling' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
Looking in the file, it is indeed not there.
I have been updating NuGet packages, so I'm assuming it's been moved\replaced with something.
Where do I need to go now to get this namespace? The internet seems quite quiet on this.
OK, the solution was odd. Not sure how the project ended up in this state.
The fact that the reference was pointing to C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Http\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Http.dll showed that it wasn't using the assemblies provided by the package, which were in the packages folder.
I had to explicitly delete the references, then roll back the version of Microsoft.AspNet.WebApi.Core as VS wouldn't let me uninstall it as the project wouldn't compile (at least I assume that was why, never had that before though).
That re-added the assemblies with the correct paths, that being, paths to the packages folder.
I also stuck and your suggest solve my problem
my step is here
remove Reference System.Web.Http
remove Nuget Microsoft.AspNet.WebApi.Core
restart Visual Studio
try to install Nuget Microsoft.AspNet.WebApi.Core again

The type or namespace name 'Testing' does not exist in the namespace 'Microsoft.AspNetCore'

I pulled the latest code from https://github.com/aspnet/MusicStore/tree/dev
Modified the code to add few imports
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
And I built the application for dotnet cli
Command used
c:\...\...\Musicstore>dotnet.exe restore
c:\...\...\Musicstore>dotnet.exe build
I get the below error
The type or namespace name 'Testing' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
The same code base worked initially , however it fails to build now
Is there any changes made to this package ?
you mean?
dnu restore
dnu build
(https://github.com/aspnet/Home/wiki/DNX-utility)
For those who will come here with the same problem:
Just add another source to your nuget settings
https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json
then install Microsoft.AspNetCore.Testing via nuget as usual
I had a similar problem and the following worked for me:
1.) Build -> Clean solution
2.) Build -> Rebuild solution
3.) Exit
4.) Open VS
Hope it helps!

from 4.5 to 4.0 :The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft'

I was working on .Net 4.5 used SignalR 1.1.2 and everything works fine.
Then we want to lower the version of netframework to 4.0 cos of production server, everything stopped and this error appeared. Please tell me what to do?
The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Solved problem by removing reference from project then build. After failed Build Add reference. Working perfectly in .net 4.0.
We can also Uninstall then install nuGet Packages.
Solved by deleting the contents of bin and obj folder on my project folder, then open the project and rebuild.

Resources