ASP.global_asax is missing from compiled Assembly - asp.net

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

Related

Visual Studio Intellisense/"Assembly Not Referenced" Issues

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.

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 or one of its dependencies for all packages in project

My pc crashed while my asp.net web application began to run. It did not fully load when this happened. When my pc was restarted, the web application would no longer run. I kept getting 'Could not load file or assembly 'name' or one of its dependencies' for all my packages. First time I got the error for one package so I re-installed it and ran the web application again, then a got the same error with a second package and I did the same. This was a continuous cycle and I could not do this for each package I have installed in the project because there are so many.
I tried many solutions that were posted for a single occurrence of this error such as here, and others but these have not solved my problem.
Does anyone have a solution to this problem? Or know why it has happened?
Sorry my friend... this sounds like corrupted manifest files to me (I recently had the same issue). Unfortunately I could not find an elegant way to fix it, although I do have some tips on how you can fix it (albeit an arduous process):
Make sure all your assembly bindings redirects to the latest versions of all your assemblies. MSDN Article on assembly binding redirect Another MSDN article on assembly binding redirect
Set build output to verbose (In VS2013 > Tools > Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity. You then need to evaluate the build output from your Visual Studio output window during build to determine the causes of assembly conflicts within your solution as well as were you might find the conflicting assemblies within your solution.

'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.

Resources