I haven't been able to find an answer to this and have been scouring the internet all weekend, so I was hoping maybe you could help me out with this.
When using Visual Studio 2012, I create a new MVC4 Web Application Project and get some compilation errors.
Here is my problem:
I create a new MVC4 Web Application using Visual Studio 2012, I select Internet Application and set it to use RAZOR Engine.
I go to Application Properties and under the Application Tab I change Target Framework from .NET Framework 4.5 to .NET Framework 4.
The build produces the following errors:
Error 1 The type name 'TableAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 21 6 MvcApplication1
Error 2 The type or namespace name 'Table' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 21 6 MvcApplication1
Error 3 The type or namespace name 'DatabaseGeneratedAttributeAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 25 10 MvcApplication1
Error 4 The type name 'DatabaseGeneratedAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 25 10 MvcApplication1
Error 5 The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 54 10 MvcApplication1
Error 6 The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 54 10 MvcApplication1
Error 7 The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 87 10 MvcApplication1
Error 8 The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 87 10 MvcApplication1
Simply Reinstall EntityFramework:
Go to Package Manager Console
Uninstall-Package entityframework
Install-Package entityframework
that is it the error should go away!
In fact, it is not a problem of MVC4 template project but of changing the target .Net Framework.
When you create a new MVC4 project in VS2012, it will (by default) reference .Net 4.5. All files are generated based upon this version. The AccountModel use new attributes from System.ComponentModel.DataAnnotations (TableAttribute, DatabaseGeneratedAttribute, ...
Retargetting the framework version only change references and does not affect source code : attributes from 4.5 framework will not be removed.
If you want a MVC4 projet with .Net 4.0, you could :
Removed .net 4.5 attributes from AccountModel
Remove AccountMode if it is not require
Select .NET 4.0 in the Create a New Project Wizard.
The Uninstall-Package entityframework / Install-Package entityframework solution didn't work for me. Instead I had to open the .csproj file in notepad and do a find and replace "net40" to "net45" to force it to load the .net 4.5 version of all the packages. This made the correct version of EntityFramework load as well.
Related
I'm trying to add Linq-to-SQL data classes to Unity project but I get an error:
Assets\Scripts\DataClasses1.designer.cs(46,65): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
I need to use Linq-to-SQL in my Unity project.
When I add System.Data.Linq.dll and System.Data.dll to my Plugins folder, I get these errors:
Loading assembly failed: "Assets/Plugins/System.Data.dll"
Loading assembly failed: "Assets/Plugins/System.Data.Linq.dll"
Does anybody know how I can use Linq-to-SQL in my Unity project?
I already set Unity-> Player->Api Compatibility Level->.net 4.x but it does not solve the problem.
I've got MVC.Net application in my TFS2015. My Applications builds & runs fine in Local. I'm configuring CI/Cd pipeline for this application. Please find the error specified below
Error CS0234: The type or namespace name 'WebApi' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)
Error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'System.Net.Http' (are you missing an assembly reference?)
I've tried both MSBUILD & Visual Studio Build tasks in my pipeline, still same error occurs
The type or namespace name 'WebApi' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)
According to the error message, it seems you are missing the references when you build with Azure DevOps. You should add nuget installer tasks to restore the package:
NuGet Tool Installer task
When we build the project/solution on local machine, the packages is downloaded stored in the \packages folder, this folder is ignored by the source control (This is recommended.) when we submit our source code, so when we build the project/solution on the Azure DevOps, we need add nuget restore task to restore nuget package before we build it.
If you have already use nuget restore in your pipeline and still get that error, please share the warning info in your build log.
Hope this helps.
I've copied the missing dll's from
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades
To
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2
Thanks #Leo Liu -MSFT for suggesting this article. It worked for me
i just cant register some dll files that has been built with .net framework 4 in some systems that both client and extended versions of .net framework 4 is installed, when i copy regasm.exe from .net framework 4 folder and paste it among some dll files that i want to register them using regasm, it gives me this error :
"RegAsm : error RA0000 : Could not load file or assembly
'file:///file address/RegAsm.exe' or one of its dependencies.
Operation is not supported
. (Exception from HRESULT: 0x80131515)"
i use regasm like this :
M:\file address\RegAsm.exe M:\file address\myfile.dll
note : when i copy regasm from .net framework version 2 and use it, i don't have such a problem.
but i need to register some dll files that has been built with .net framework 4.
note 2 : i must add that in some systems like my system that visual Studio 2013 is installed, there isn't such a problem.
i saw questions like this with their own answers but their talking about this that regasm cant register some dll files, but in my case it gives error about its own self.
UPDATE
thank you jeff
I changed my registering command to something like this :
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe M:\file address\myfile.dll
and now it's giving this error about my own dll files, but i know that i have all of the dependencies in the folder, this is the error :
RegAsm : error RA0000 : Could not load file or assembly
'file:///M:\file address\myfile.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515)
RegAsm is a .NET application with its own dependencies. The CLR is failing to load one of those dependencies when you copy the exe by itself to another computer. If .NET 4 is in fact installed on that computer, RegAsm.exe should be in the .NET directories under Windows and you shouldn't need to copy it from another computer.
I have downloaded the KinectToolbox from the codeplex website and added Kinect.Toolbox.dll into the reference in my project, but when I put "using Kinect.Toolbox" I get the error "The type or namespace "Toolbox" does not exist in the namespace 'Microsoft.Samples.Kinect' (are you missing an assembly reference?)"
Any suggestions?
I am getting an error:
Error 1 The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?) c:\users\klippiat\documents\visual studio 2010\Projects\TfsPortal\TfsPortal\Models\ApiModel.cs 5 23 TfsPortal
I would normally Add Reference and select the missing reference. But System.Web.Http.Description is missing from the list. I have sorted the list by name to make sure that I should be able to see it. I can see System.Web.Http.Data and .Common etc. but not the .Description one.
What am I doing wrong?
Visual Studio 2012 SPA Template /Help/index.cshtml file was throwing your error.
#using System.Web.Http
#using System.Web.Http.Description <=== CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
Solution: Set "Copy Local : True" in properties for References\System.Web.Http
You aren't doing anything wrong. There is just some configuration problem that prevents Visual Studio from adding the reference to the list of assemblies for the compiler to check.
Types in the System.Web.Http.Description are found in the System.Web.Http.dll assembly, which is found in a Nuget package folder.
You can type Uninstall-Package Microsoft.AspNet.WebApi in the NuGet Package Console and then type Install-Package Microsoft.AspNet.WebApi to re-install it at which point, the reference will be fixed.
I un-installed MVC4 and reinstalled from a fresh download. I had to create a NEW project again and the Description namespace appeared.
The strange thing is if I open the old project the Description namespace is still missing when I try to add a using...
I was also facing the same issue when while creating a SPA solution by using MVC-4 framework.
I resolved this by setting the Copy Local : True in properties for the reference System.Web.Http.
I had the same problem. I was opening the project as a website instead of project/solution. So, after opening the solution it solved my problem.