Visual Studio Intellisense/"Assembly Not Referenced" Issues - asp.net

After getting latest in Visual Studio 2015 Community, some of my Razor syntax is showing red Intellisense errors. Items like #Html.TextboxFor() and #Html.CheckboxFor() are throwing the following error:
The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I have attempted the solutions listed under the following: VS 2015 IntelliSense: Assembly Not Referenced Error, The type 'Expression<>' is defined in an assembly that is not referenced.
Neither one of these issues fixed the problem. Are there any other issues that could be causing this problem?

We just resolved this by disabling VS tool extensions, one of them interfered with intellisense and drove us nuts for two days.

After uninstalling and reinstalling VS again, it appears that the problem has been taken care of. I'm sure that there must be a better solution.

Related

General Advice for Resolving Dependencies (could not load file or assembly bla bla) in .NET 4.5

I'm new here to go easy.
I'm trying to publish my first asp.net 4.5 mvc 4 site to windows azure and I've got dependency issues. I can see that there are a plethora of existing posts and each one contains slightly different advice so I would appreciate general advice for troubleshooting these dependency issues. I'd be hugely grateful if you treated me like a layman in all regards.
For e.g.: my first publish error was:
Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
This is not referenced anywhere in my project in code, but has a reference to the assembely when I manually check (and the same version that the errors throws up, 4.0.0.0)
Now that I've tried to publish, I get an Oath error when I try to run locally that I did not get before:
Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified.
As per this post Could not load file or assembly 'DotNetOpenAuth.Core I've since solved that particular issue which seemed to have arised post-publish by deleting the bin/obj folders, cleaning solution and changing some publish file settings.
Since then I get just another dependency issue:
Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
(Again in my references list with the "runtime version" as v4.0.30319 and "version as 2.0.0.0 in the properties tab, so I have no idea what to do with it)
So my final question is thus: what is the general process behind resolving these? I cannot google each one in sequence as they are slightly different each time and perhaps sometimes they may be referenced in packages.config and perhaps others not.
Is the process for example: check reference to assembly, if it exists then uninstall and re-install manually from nuget? Is there no automated way of doing this? And why can't I run locally anymore since I attempted to publish? I expected publishing to azure to be seamless and I'm a little disappointed.
Needing desperate help and thank you all,
Lani
EDIT1: to answer cory's question, here's a file explorer screenie and files showing up in VS with 'show all files' selected: https://www.dropbox.com/s/f8qguuwicxz71ws/Screenshot%202014-10-19%2020.31.25.png?dl=0
I honestly don't know if that answers your question.
EDIT2: I've tried pointing the packages.config file to 4.0.0.0 for dotnetopenauth.core as per the error but the system cannot find any prior packages. I've also gone to http://www.nuget.org/packages/DotNetOpenAuth.Core/5.0.0-alpha3 but it displays a list from 4.3.2 to 5.. I really think something is wrong in the project rather than for e.g. dotnetopenauth.core version... (or any other dependency issue that will inevitably arise after I resolve this one..)
These dependencies are done on the Web.Config file apparently on the <assemblyBinding> portion. You may also reinstall Nuget package.

'Could not load file or assembly' compilation errors

Like many others I am getting the "Could not load file or assembly ... .dll". This problem happens when I try to compile as there is then a single error. I have tried adding a reference to System.Data.Entity and rebuilding, as well as also trying various things out from this stackoverflow answered question:
Could not load file or assembly 'System.Net.Http, Version=2.0.0.0 in MVC4 Web API
I have tried the "Copy Local = True" under properties under References for the particular .dll (It was already set to True), as well as "Always Copy" the .dll in question which is in the bin folder.
I have also tried to find the "runtime" code in the Web.Config file, there however is none in either that or the sub-files (web.debug.config and web.release.config). I thought that perhaps I could modify the version. There are about 10 other .dll references which seem to be working. I also did get the compilation and part of the first page to run the first time, but not after that. Error information is at the bottom.
I have read that there seems to be a problem with NuGet but I don't know if I should remove it as I don't know what it does and might find it useful later. I am using Visual Web Developer Express 2012.
'Could not load file or assembly 'ComponentArt.Web.UI, Version=2008.1.1202.3, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)' C:\Users\Brian\Desktop
I think you might be using the ComponentArt dll that depends on WebForms in MVC4 project. You need to create a WebForms project and then you will be able to add that DLL.

find out what references dll

I just solved the following error:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
Strange thing - it only seemed to be a problem when I made a release build although was a little intermittent - I could create a debug build and the issue could sometimes temporarily go away.
Turned out that I had an enterprise library dll in the project Microsoft.Practices.EnterpriseLibrary.Data.dll that wasn't being used, was version 5.0.505.0, and looks like it was trying to pull in v. 5.0.505.0 of Microsoft.Practices.EnterpriseLibrary.Common, when v. 5.0.414.0 of this 'Common' dll was already in the project. Didn't pin down why this was mainly happening in release mode.
Something that would've helped to track this down and clearly identify the cause would have been to find out for certain which dll is pulling another dll into my Visual Studio project? I want to be able to go from the dll that's causing the problem, and see what dll is including it. This answer:
Find out why Visual Studio decides to copy DLLs into a bin directory
says that ildasm or reflector can be used, but what do you need to look for using these tools and how? I've Googled this but didn't see anything.
As a side note, any ideas on why switching to release mode would cause my issue? I've wondered if doing this caused Visual Studio to attempt to pull a release version of Microsoft.Practices.EnterpriseLibrary.Common from somewhere and it's the wrong version, but this makes no sense to me as this is a '3rd party' (Microsoft) library that is already in release mode, it doesn't explain the intermittency, and I don't see why switching an individual project to release mode would affect a reference to an external library.

ASP.global_asax is missing from compiled Assembly

I am using aspnet___compiler.exe to compile my asp.net 3.5SP1 websites,
then aspnet_merge.exe to merge the assemblies into a single one.
The assembly is then uploaded to the production server. This usually works pretty well but sometimes when testing on the staging server I get the
following message:
Parser Error Message: Could not load
file or assembly 'App_global.asax,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. The system cannot find
the file specified.
When looking at the assembly with Reflector and comparing it with a working version of the same assembly I see that the type ASP.global_asax is indeed missing.
When changing something on the site and compiling it again, I get a working version that includes 'ASP.global_asax'.
This is kind of annoying, I am wondering whether this is a bug in the compiler in some special circumstances?
Anybody else encountered this and found out how to fix it?
I've been running into this issue today and found this:
http://blogs.msdn.com/b/isha/archive/2009/04/04/issues-with-wcf-service-when-the-asp-net-website-is-deployed-using-the-web-deployment-project-and-as-non-updatable-project.aspx

ASP.NET MVC 2 System.Web.Mvc.dll conflict

I have installed the ASP.NET MVC 2 RC and opened the default "example project", but get the following error:
Parser Error Message: The type
'System.Web.Mvc.ViewMasterPage' is
ambiguous: it could come from assembly
'C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mvc\2.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' or from assembly 'C:\Documents and
Settings\sfent\My Documents\Visual
Studio
2008\Projects\MvcApplication1\MvcApplication1\bin\System.Web.Mvc.DLL'.
Please specify the assembly explicitly
in the type name.
This appears to be a conflict between the GAC dll and the dll created and placed in the bin directory (which I thought was supposed to be used in preference to the GAC version)
I have Googled this issue and have found similar problems, but relating to incorrect namespacing. This is the un-altered example application that comes bundled with the MVC framework.
I have also tried removing the framework entirely and re-installing the RC, but to no avail.
All suggestions appreciated.
I got this error, and in my case it was resolved quite easily.
I had made a new Master Page in my Views folder, but unnoticed by me, it came with code behind and designer, which of course you don't want with MVC2. It all built, but gave me that "Parser Error Message: The type 'System.Web.Mvc.ViewMasterPage' is ambiguous:..." error when I ran it.
To fix it, I removed the code-behind and designer files for my new Master page, and the error went away.
the problem might be that the Reference in your Project is still pointing to the old Version of the dll (v1.0). Delete the reference and add a new one to version (v2.0).
You find that hint as well in the release notes of MVC2 RC:
"Open the project using Visual Studio, and in Solution Explorer, expand the References node. Delete the reference to System.Web.Mvc (which points to the versionĀ 1.0 assembly). Add a reference to System.Web.Mvc (v2.0.0.0)."
Cheers,
Damrod
Does your project reference both v1 and v2 of the framework? Also, why not delete the matching dll that's been copied locally?

Resources