CS0234: Missing Assembly Reference - asp.net

I have some missing assemblies in my PC, and don't have any idea how to fix it.
When I create a new ASP.NET MVC 4 internet application from template (using VS 2012) everything works fine. As soon as I try to integrate Web API controller I get a missing assembly reference error. For example, when I create application using ASP.NET 4 Web API default template and click "API" on the interface I get Compilation error:
Compiler Error Message: CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
I have checked the assembly and everything seems to be fine. It's in version 4.0. I have .NET framework 4.5 installed on my PC. Where should I look for the reason of the issue?

I saw this same error code (different missing reference) when compiling a PCL using msbuild but not when building via Visual Studio:
error CS0234: The type or namespace name 'Storage' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
In my case it was caused by a 'using Windows.Storage;' statement that was not actually referenced by any code in the file. I removed the line and the error was fixed.

Related

Blazor WebAssembly no longer builds successfully

Each time I try to run Blazor WebAssembly, I get this error
/Users/mac/Projects/test412421/test412421/Client/Program.cs(40,40): Error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (test412421.Client)
Can anyone help? I've re-installed the SDKs and Visual Studio several times

The type or namespace name 'Web' does not exist in the namespace 'System'

I am building a project in .NET Core where I need to use the Framework Assembly System.Web.Extension. I install the assembly via Reference -> Add Reference -> System.Web.Extension 4.0.0.0. After it installed it appears under DNX 4.5.1 -> FrameworkAssemblies. Package restoration was successful as well.
Following entry is added in project.json file as expected.
"frameworkAssemblies": {"System.Web.Extensions": "4.0.0.0"}
But when I am trying to compile the project using dnu build, following error appears!
D:\Projects\ColemanApi\src\ColemanApi\Controllers\ValuesController.cs(7,14): DNXCore,Version=v5.0 error CS0234: The type or namespace name 'Web' does not exist in the namespace 'System' (are you missing an assembly reference?)
D:\Projects\ColemanApi\src\ColemanApi\Controllers\ValuesController.cs(51,27): DNXCore,Version=v5.0 error CS0246: The type or namespace name 'JavaScriptSerializer' could not be found (are you missing a using directive or an assembly reference?)
I was following this post but it does not have a solution for .net 5 or I don't know how to Copy Local in .net 5 as I did not see any Properties option in Assembly's fly-out menu.
Please see attached image:
And here is a screenshot of the compilation error:
Somebody please help. I am totally screwed up!
UPDATE
I ran dnu list and it shows the System.Web.Extensions is resolved. Please see the screenshot below:
Thanks in advance.
If it does, is there any alternative solution to deserialize a JSON string without removing "dnxcore50"?
JSON.Net provides this functionality. If you want to use this on Core...
https://github.com/JamesNK/Newtonsoft.Json/issues/618#issuecomment-186441534
There won't be any progress until .NET Core RC2. When it is released I'll create a netstandard build and release a new version of Json.NET.

SQLite and ICSharp.ZipLib is giving errors during build app in release mode

i am working on windows phone 8 app. I am facing following errors, you can see the name of dlls in mentioned messages which are working in debug mode. But when i am building my app in release mode than these errors are coming. any idea ?
1)The type or namespace name 'ICSharpCode' could not be found (are you missing a using directive or an assembly reference?)
2)The type or namespace name 'Community' could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'TModel' could not be found

I'm trying to publish a MVC4 application into appharbor, copying locally System.Web.MVC but still getting this error.
error CS0246: The type or namespace name 'TModel' could not be found (are you missing a using directive or an assembly reference?)
Have you tried to use the NuGet dll - please make sure you're referencing the NuGet dll and not your local system one: https://www.nuget.org/packages/aspnetmvc
Also check out this support issue: http://support.appharbor.com/discussions/problems/1314-error-pushing-mvc4-application

asp.net mvc 4 website is refusing to build on teamcity

I have a Windows Server 2003 box with teamcity that I use as a build/deployment server. I checked in a new asp.net mvc 4 project and it is crapping out with the following errors:
App_Start\BundleConfig.cs(2, 18): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Controllers\AccountController.cs(8, 7): error CS0246: The type or namespace name 'DotNetOpenAuth' could not be found (are you missing a using directive or an assembly reference?)
Global.asax.cs(7, 18): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Models\AccountModels.cs(4, 45): error CS0234: The type or namespace name 'Schema' does not exist in the namespace 'System.ComponentModel.DataAnnotations' (are you missing an assembly reference?)
App_Start\BundleConfig.cs(9, 44): error CS0246: The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?)
I've already installed asp.net mvc 4 on that box, restarted the machine and tried everything else without any luck.
Any ideas?
For me, my CI server (TeamCity) wouldn't take MVC 4 via the Web Platform Installer. Dunno why.
So I checked the TC build logs logs for the yellow warnings, looking for references its trying to resolve.
For each one, I then looked for the corresponding NuGet package in the project/solution and reinstalled it. This sets it up with package restore so that TeamCity/MSBuild restores it during build.
For example:
Update-Package WebGrease -Reinstall
The MVC project template, although it uses NuGet packages, they're not wired-into the whole package restore mechanism for some reason, so reinstalling them forces this. Effectively, I suppose you're installing MVC 4 via its constituent packages.
Luke
A few things I would look in to:
Make sure that your NuGet packages are being pulled down appropriately during the build. Documentation
Make sure that the project is not still referencing the old MVC 3 assemblies somewhere. Perhaps a nant/msbuild build script is copying the old assemblies somewhere?
I am not sure if this will be helpful. But I had same problem. What I was trying to do is using EnableNuGetPackageRestore I was trying to restore it and some where it was causing problem (Restoring nuget packages from Test project rather than MVC project. I am not sure why but if I found out I will surely update thread). What I did is I followed blog from http://blog.jetbrains.com/teamcity/2013/08/nuget-package-restore-with-teamcity/. Adding one more build step NuGet Installer helped me fix issue. (Caution: If you are using internal nuget package server than you need to specify same in Sources). Please let me know if you have still problem and I can be of any help. Happy Building !!

Resources