My C# web application stopped working for no apparent reason, while a similar application on the same server still works. Looking for ideas what could be going on and how to fix it.
Yesterday I launched a build of the site with some minor updates. The server apparently went down during the build, because for a few minutes TeamCity displayed a message indicating the connection had been lost. However, it recovered and resumed the build.
After the build, I was no longer able to load the site. The home page now seems to be the only page that can load, and it displays incorrectly because the scripts and stylesheets fail to load. If I check the browser’s error console I find reports of multiple server error 500’s, where the referenced css and script files are failing to load.
The server is IIS on Windows Server 2008.
If I go to the server and open the site there, the page gives me error messages saying, “Could not load file or assembly ‘Antlr3.Runtime.Debug’ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)).”
Initially it was reporting the same message for a different file, AntiXssLibrary. I removed that DLL from the project, and the site switched to complaining about antlr instead. It looks like the problem isn’t either DLL, but something else.
On my machine, a nearly identical copy of the same code works without problem. Another copy of the site on the same server, a slightly earlier version of our software, works just fine.
I deleted all of the temp files recommended for this error, redid the build, restarted the machine, and deleted the bin directory and repeated the build. I’m skeptical that uninstalling or reinstalling any versions of the .net framework would help, given that the other site works—any problem with the frameowkr ought to affect both of them.
I turned on assembly logging, which gave me lots of additional information that didn’t help at all.
Any suggestions what could be going on?
Edit: a link below suggests that the problem is corrupted temp DLLs, and that deleting and recompiling will replace them with good copies. That's plausible. But it seems like re-running the build ought to recompile if anything is going to.
Might there be some other way to force it to recompile / update the DLLs?
Related
We're experiencing an issue with ASP.Net runtime compilation.
At the start (and after restarts) of the IIS, user controls and layouts compile just fine without any problem. But at some point during the lifecycle, the runtime compilation simply stops working. A restart of the IIS process makes it work again.
After searching through a myriad of different posts, we've done some extra debugging, but we are still stumped as to what causes our problem.
To keep this to the point, I'll skip explaining all tests we have done, and jump right to what I believe is closest to the heart of the error.
We have switched our compilation.tempDirectory to a custom folder used exclusively by this web application, and we have set a procmon to see all file changes in this folder. Once the error starts occuring we can see that the temporary files are actually written to this drive, and csc.exe is started (and during this, conhost.exe, CcmExec.exe and many other processes), we see no errors in procmon, but after csc.exe has run, it deletes the temporary files without leaving the compiled versions. (and the asp.net error screen shows us csc.exe failed, but not exactly what failed). The temporary files are all created (except for the resulting dll) - .0.cs, .1.cs, .tmp, .cmdline, .out, .err are all there for a short time. But immediatly after creation, they're all deleted again, and the application cannot find them.
Does anyone have any clue as to what causes this to fail after the process has run for a while? The exact same file compiles just fine if we run it just after an IIS restart, but after a while it seems that something during the runtime compilation fails, causing the ASP/w3wp/csc process to delete all signs of the temporary files, not creating the dll, and making the functionality fail.
Finally figured out what caused my problem.
We had an external module installed, which ran another third party exe file to do some optimizations. Running external programs, starts a conhost.exe process under the application pool identity.
The second third party (the exe) could under some circumstances fail due to file locks, which caused the exe as well as the conhost.exe to hang. Once enough conhost.exe's were running, the application pool were no longer allowed to start new ones to run the runtime compilation. This caused the runtime compilation to fail, and the web application to automatically clean up the temporary files.
I have looked at the other answers to similar error mgs, but none of the answers seem to work.
I am trying to debug an asp.net mvc 3 application using vs 2010 on a windows xp machine.
This application was working fine, yesterday I was jumping between two applications , copying code etc.
Then today I get the below error when trying to run (it builds no problem)
The only difference was when I opened the application in Visual studio today, a window appeared before program loaded stating the following...
URL http://localhost:1697/.
The Web project "MyProject" is currently configured to use the (url from above line goes here)The Web server has this URL mapped to a different folder "C:\Projects\MyotherProject". Would you like to remap this URL to this Web projects folder ?
..........I assumed I hit yes...and I got the error below
Server error in'/' application
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.
I have tried, clearing out the bin and obj folders and then cleaning and re-building.
I don't understand where/what the problem is ? can anyone advise ?
That usually means you are missing a reference in your project to the mentioned assembly, or a version conflict, at which point:
A web.config entry could trigger that exception
Some of the code you copied may be dependent on said assembly/version
Default scaffolding in VS, does include sample/working authentication code (e.g. DotNetOpenAuth.Core - you'll usually find this in the Accounts folder (web site, web app, etc.)
Some other items to check
you mentioned Win XP, does this box have version parity (at least .Net/ASP.Net) installed with the dev box that the project was (originally) created?
you could use Web Platform Installer to figure this out and then load the needed assemblies at the same time
is there a package.config file in the project? That could help too - just so you know your dependencies (then make sure you have them in the debugging box).
So, I've had to rework a web app on one of our servers, a legacy app, that needed to get new branding via a common master page, where it previously had none. The page displays ok, but there's a form on it that calls a method in a compiled dll which allows the user to download a document. This throws an error, but the error is vague (mentioning a null reference). We have the source code but I don't have visual studio installed on my machine and even if I did we suspect it may have something to do with the server environment, and the server is not set up to run project files, just compiled web apps. One of my colleagues thought that by removing the dll, the app would just use the cs files and compile that at run time. That didn't work, and another colleague suggested turning debugging on in web.config, which we did, but still no go. He also mentioned that debugging required pdb files, but I don't see any in the source code we have. If I could get this working on the server just using the cs files vs. the dll, I could at least attempt to debug what's going on, any ideas on how to get that working?
There seems to be a good deal of confusion here about how ASP.NET applications work.
First, .CS files are meaningless to IIS. IIS knows about files containing markup. It also knows that the assemblies contained in the bin folder represent the server-side code that handles the incoming requests and generates the outbound responses.
In most cases, when a site is deployed to a production server, the .CS files are not included, because they are just noise on the server, useless file clutter that have no bearing whatsoever on the execution of the application.
Now, you're kind of lucky, because you have the source files there. You can, actually, force a recompilation of the cached assemblies. To do this, open the site's web.config file and add some whitespace (a single space) to the end of the first line. Then save the file. This will cause ASP.NET to clear its cache and rebuild the site.
This isn't guaranteed to get rid of your problem. Like you say, the problem could be somewhere else. What I would strongly suggest is that you download the site in its entirety, install Visual Studio (get a free express edition if you have to), and DEBUG the darned thing.
If you can't run it in a debugger and watch it execute, you're just guessing.
PS If this thing isn't under source code control, get it there, ASAP.
When I try to build my project, it returns the following error:
Error 1 Unexpected error creating debug information file 'D:\Documents\Lance\Documents\School\Capstone\GG\GG\obj\Debug\GG.PDB' -- '' GG
I've recently had the misfortune of having my PC restart on me, due to sudden power supply problems (maybe). This is while the project was building, before this problem started.
When the PC came back online I've noticed that the changes I've made to the program prior to the sudden power down was not saved. And, it won't build anymore.
This worked for me:
Shut down VS.NET
Browse to the project in Windows Explorer
Delete the /obj/ folder.
Delete the project outputs (.dll and .pdb) from /bin (not sure if this step is necessary)
Can't hurt but might help: delete the project outputs from any other project /bin folders in the solution that is having issues (wasn't necessary for me)
Restart VS.NET
Rebuild
http://weblogs.asp.net/ssmith/archive/2003/08/12/23755.aspx
As requested, my comment as an answer:
Try cleaning the solution (under the Build menu in VS).
Since the build was interrupted half-way through by your power failure, the file isn't locked -- the build system is probably just in an inconsistent state (which a Clean Solution should fix).
This happens once in a while in my environment and the problem probably has to do with the PDB file being locked (i.e., I'm guessing the last part of the error message is missing in your post). This is how it looks on my machine:
Unexpected error creating debug information file 'c:\dir\obj\file.PDB' -- 'c:\dir\obj\file.PDB: The process cannot access the file because it is being used by another process.'
In my case, cleaning the solution does not solve the problem and restarting is an overkill, so I usually just copy the full name of the pdb file (from the error) and execute this on the command line:
ren c:\dir\obj\file.PDB *.old
This worked for me: Close Visual studio and open visual studio using Run as Administrator and problem was solved.
Not need to restart or delete the file.
Just rename the file and that is enough. If you try to delete the file it will give an error. Better just rename it & it will work. :)
If you are having this problem with a web application, this can happen in the unusual situation that you have used DebugDiag and created a rule that listens on your project's app pool. Deleting the rule prevented this problem from recurring.
This might happen, for example, if you followed these instructions for diagnosing a stack overflow exception in IIS.
If you are working on VM with two user, make sure the other user has not attached all the process while debugging.
Cons of restarting VS:
Clipboard will be lost
Redo/undo will be lost
Files open will be lost
You will loose the tempo
Solution:
Give your Assembly a new name. No cons. Except you will have to rename your assembly back to its original name when you are ready for final deployment. And I think anyone can find how to make it work for the last time :)
Sometimes all the files from \bin folder are used by a running process, i.e. web site on IIS or windows service run automatically after build. In such cases turning off the service or stoping IIS app pool for specific site should also help (like in my case)
Sometimes I run into this problem, when compiling the same project for (very) different targets:
VS2008 and net35
VS2017 and net462
dotnet core 2.0
My guess is, that either bin and/Or obj directory are used by the compiler, but the outputs are not compatible (of course). Solution clean from VS indeed helps.
Often we specify different dll names for the output (e.g. mylib.dll, mylib35.dll) and the issue never happened on those projects.
I'm working on a moderately sized WebForms project. Due to the peculiarities of management here, I have to upload the site to a remote server in order to test (no localhost testing). I'm using the 'Publish' command in Visual Studio 2008. Sometimes, it even works. Most of the time, I inexplicably get a "publish failed" in the bottom left corner, with no further details.
The few googled articles/forum posts I read suggested making the target local folder for the publish operation readable/writable for everyone. Doesn't help.
Is there are way to get further details as to WHY a publish fails in VS2008, and if not, is there a better way of doing these deployments? I'm spending more time building/pushing to the web server than actually debugging.
It's worth checking the output window. I've just had a publish fail because I had deleted an image outside of VS so VS was complaining that the image couldn't be found, but this information was only displayed in the output window.
See this link for more information:
http://ericfickes.com/2009/08/find-out-why-visual-studios-publish-fails/
It happens to us when there is an error in markup (!). Bad thing is that VS will just swallow the error and just tell you Failed.
What I suggest is to run your publish from command line using MSBuild. It's not that straightforward but it works (once you get into it).
I've since discovered that the reason for these particular publish failures was due the "Delete Existing Files" option being checked. Using Visual Studio 2008 under a non-administrative account on Windows Vista could cause a permissions error while attempting to delete the existing files. The publish would fail silently after encountering a file that Visual Studio had insufficient access to delete. Once the files were deleted manually outside of Vidual Studio, the publish functioned normally.
I have not had this issue with Windows 7; I assume the UAC changes in Windows 7 fixed the problem.
I mostly work with Web Forms, and I encounter this problem daily.
It seems to me that publish fails when it fails to delete a file it is trying to replace. Even if I don't have any files open, it still fails sometimes. Not sure why.
Not only VS publish fails very often, it is painfully slow as well.
I just publish to empty local directory and use separate FTP client to upload files. It's more work, but works.
This is probably not the case for you, but I've seen this happen when I'm publishing a web site. If the app_offline.htm file is not excluded from your project (if you use this file), the publish will fail.
Same happened to me.. what I did was include images files that was not included in the project and delete images that were not used.
After struggling with a similar issue for about 30 mins with no clue as to what was causing it closed down VS and reopened my project. Started working fine. No idea why but it worked.
You should always stop the IIS instance running on the machine your are publishing to. Google the word "iisreset". Other hosting providers like DiscountAsp and Arvixe offer you tools to "Stop" and "Start" your app pool on their IIS remotely. This is very necessary because IIS may have locked some files as "in use", so your publish fails when it tries to write over them. When your publish is complete, then just restart IIS (or press "Start" from a web tool if you're using a 3rd party hosting provider).
When all else fails, check your "Output" window (the tab to the right of your "Error List" at the bottom of Visual Studio). Scroll through all of it after a failed publish and look for anything that says "Unable to add". If you keep seeing the same "Unable to add" errors on the same publish, then ftp into the folder, delete the the problematic files manually, and try publishing again.
I got this when my ProjectName.Publish.xml file was read-only. Once I checked the file out of source control, I no longer got the error and could publish.
Just to add to this thread, I found that, for some bizarre reason, only the Mercurial files were being published to the server, everything else just wasn't being copied across.
Another strange thing was that only the Debug configuration was available; Release was nowhere to be seen.
After reading other threads around S.O., I found that there were many for VS 2010 and 2012, but not much to cover the same problem with 2008.
The fix, I found, was to delete the [solution].suo file and then attempt a publish. That seemed to do the job, though it took a long time to complete.
What I found and work in my case. It is to use a different version of VS.
I recently had the problem, the solution works perfectly in VS2015 build, compile and tested.
However, when I try to publish was failing silently.
So, I closed the solution and open it with VS2017 that use the same file structure for the projects/solutions. Then rebuild it and publish without any problems.
I believe it could be VS related and it is complicated to debug.
This is a workaround if you work with multiple Vs instances in your local machine.