I'm converting a .net core 1.0 project to 2.2 net core
There is a reference to System.ComponentModel.DataAnnotations I'm trying to resolve, has this been factored into a seperate nuget package in .net core
Error CS0234 The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)
Adding references to Microsoft.AspNetCore.App and Microsoft.AspNetCore.All cleared the error.
Related
I am using Microsoft Visual Studio Community 2019, Version 16.9.2.
I have started a new Blazor WebAssembly project, target framework is .NET 5.0 and the project is configured for HTTPS, and the ASP.NET Core hosted option is selected.
The problem is when I try to Install Microsoft.AspNetCore.OData nuget package (version8.0.0 pre release 3).
After Installation, I build the project, and I got the following error:
CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
Build started: Project: WebApplication1.Client, Configuration: Debug Any CPU
CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
Any help will be highly appreciated
Thanks
How to add standard .Net references such as
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
When trying
using (System.Drawing.Image I)
I get the error
Severity Description File Line
Error The type name 'Image' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcdxxxxx' Consider adding a reference to that assembly.
When going into reference VS 2018 wants me to point to the DLL File.
Its really frustrating. This is a Asp.NetCore MVC web based project.
System.Drawing is incompatible with .NET Core, because it uses Windows-specific APIs not available in .NET Core. Microsoft has since released System.Drawing.Common, which is a NuGet package that provides a similar API to the old System.Drawing but uses cross-platform APIs. To make this truly a drop-in replacement, the System.Drawing namespace now forwards to System.Drawing.Common, so older code could work without change.
Long and short, you need to add the System.Drawing.Common NuGet package to your project.
One of our class library project references System.Web.Mvc using the default .Net Framework assemblies. It compiles absolutely fine locally, but when trying to setup the build on VSTS Online, it throws the following error:
Error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Should we be adding the DLL manually to be referenced ? or is there a way to tell VSTS to just use the .Net Framework DLLs ?
This DLL comes from the NuGet package Microsoft.AspNet.Mvc which means you are not correctly restoring your NuGet packages as part of your build.
We had a similar issue where the code was building fine locally but not on Azure Devops.
We had a web app and a business logic project. The web app had a dependency to the business logic project. A class in the business logic project was referencing System.Web.Mvc, but the Microsoft.AspNet.Mvc Nuget package wasn't added to the business logic project.
All we had to do to resolve this was add the Microsoft.AspNet.Mvc Nuget package to the business logic project.
Add Nuget reference to BusinessLogic
I add mapinfo dll's my project but when i want to add namespace i take error.I add MapInfo.CoreEngine,MapInfo.CoreEngine.Wrapper,MapInfo.CoreTypes and MapInfo.WebControls.I search my dlls path thats correct.
I use MapExtreme 7.3
I solved error.MapXtreme work with .net framework 4.5.2.Install .Net framework 4.5.2 and your project target framework must be 4.5.2.
I have a .NET project whose target framework is 4.5.1. This project depends on a NuGet library which only has a .NET 4.0 release and this library in turn depends on MVVMLight:
MyProject (4.5.1) --> Depends on MyLibrary (4.0) --> Depends on MVVMLight (4.0)
The MVVMLight NuGet also has a 4.5 version so when it's installed on MyProject it ends up referencing the 4.5 version (as opposed to MyLibrary which was compiled with MVVMLight for .NET 4.0).
This results in the following compilation error:
5>...\Adorners\CircleAdorner.cs(19,18,19,31): error CS0012: The type 'GalaSoft.MvvmLight.ObservableObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'GalaSoft.MvvmLight, Version=4.4.32.18939, Culture=neutral, PublicKeyToken=null'.
The error is from a class CircleAdorner which inherits from a class defined in MyLibrary which in turn inherits from ObservableObject from MVVMLight.
Is this situation "legal"? Is it OK to reference a .NET 4.0 library from a .NET 4.5.1 project? From my understanding it should be OK. However, the catch here is that the .NET 4.0 project expects another dependency which is not satisfied here.
Also, I noticed that the DLL version of GalaSoft.MvvmLight for the .NET 4.5 is 4.4.32.39728 and not 4.4.32.18939. In the project I marked this reference with <SpecificVersion>False</SpecificVersion> but it didn't help.
Yes it is legal for a .NET 4.5.1 project to use a .NET 4.0 assembly. .NET 4.5 is an in place update to .NET 4.0 and is backward compatible.
From NuGet's point of view if the version of project's target framework is less than or equal to the assembly version in the NuGet package then they are considered compatible. So NuGet will allow you to add a NuGet package that targets .NET 4.0 into a project that targets .NET 4.5. What you cannot do is add a NuGet package that only targets .NET 4.5 into a project that targets .NET 4.0 since the assemblies in the NuGet package may use parts of the .NET framework that is not included with .NET 4.0.
When installing a package NuGet will pick the highest version of the .NET framework that the NuGet package contains that is compatible with your project.
With your GalaSoft.MvvmLight version mismatch you should be able to resolve the problem using one of two options:
Update MyLibrary to use the same version of MvvmLight that your project is using.
Add a binding redirect to your project's app.config for GalaSoft.MvvmLight so MyLibrary's reference to it is mapped to the later version. If you are using Visual Studio 2013 and writing a .NET 4.5.1 desktop application you can enable automatic binding redirects instead of updating your app.config.