Debugging previously compiled ASP.Net Web App without visual studio - c#

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.

Related

All DLLS in site fail to load, exception 0x80070057

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?

Seeing file changes in the browser without rebuilding your project

I am a Front-end developer, currently working on a .net project. It was explained to me that some of the resources of the project are embedded and when I say some, I mean most of them. Therefor when making changes in the files, you can't see them in the browser without first re-running the project from Visual studio.
I believe you see how this is extremely annoying and frustrating to me. I am used to more dynamic way of working, even have something like livereload running to inject my styles and refresh the page when markup has changes, so I can see the changes in the browser without even switching the active window
I was wondering if there is anything even remotely close to what I am used to as a workflow for web development
Files including aspx and cshtml can be saved (most of the time) and will show changes upon page refresh. Occasionally, the file system may access the files and overwrite them. Files that are compiled upon build are not able to be changed unless a rebuild is issued.
In short terms, front-end is easily edited during run while code-behind and classes cannot.
You've tagged this as MVC, so that means if the view is changed it can be reloaded without running it from Visual Studio. Further, the project just needs rebuilt if you change code. You don't have to re-run it from Visual Studio.
So, in short, you can certainly still make changes in the browser with livereoload, then move those CSS changes to the CSS files in the application, and refresh your browser. That's it.
EDIT: After seeing the screenshot, change that to Content instead of Embedded.

Deleting WCFTestClient's Cache - for Visual Studio 2010

We're creating WCF services (.NET 3.5) via Visual Studio 2010. When I make a change to the .svc.cs file, save, clean, rebuild and copy to GAC (using WSPBuilder, which recycles the various IIS processes) I still get cached data. Only drastic things like checking in all my files and running a gated checkin build, or restarting the computer clear this 'cache'.
The upshot of this is that the development->testing cycle is extremely slow. But it need not be! Here's my question. Where is the cache that VS2010 or Windows is keeping for WCFTestClient? I can add debug breakpoints and the symbols show up in the debug (so that means on some level I'm using the new assembly) but key things like watches will show old, cached variable values.
Is there a cache somewhere for this data? Looking at the list of .dll files in the output that the WCFTestClient is using when I run debug(F5) shows that it uses the correct .dll (and my observations during debug confirm this.)
I just need to be able to remove (manually if needed) this cache between rebuilds of my assembly. Otherwise, I can't actually rectify problems in the code.
If I'm missing something obvious here, let me know.
Try deleting your solution .suo file.

“No symbols loaded for the current document” ASP.NET C# Project

What to do now, this time??
I hate VS and this symbolic gibberish that never seem to have same solution (if it once was logic) twice. The screendump below says what it says.
As soon as I F5/Start the web project, the breakpoint going yellow. This ONLY affect the aspx.cs file that being changed. The other aspx.cs files can have breakpoints.
When I do rebuild/build all DLL and PDB files are created just fine. They have same compile time and are in same directory. Module-Windows i VS says the symbols are loaded perfectly. Well, yeah, try bite me!
I can tell, all symbolic is working just fine, until I was about doing changes inside those aspx.cs files (which was some time ago since last time). If I reset back the file, the breakpoint are working. If I try to make changes in another file, the problem appears there.
It simply appears like that the symbolic file generator don't understand changes maded in aspx.cs files..
Have you got compilation debug="true" set in web.config?
http://msdn.microsoft.com/en-us/library/e8z01xdh(VS.80).aspx
This sometimes happens if you have changed the starting url in the Web -> Start Action -> Start URL to a different location. It could also be something in the Web -> Servers pane where something is set other as expected.
Also make sure the website in IIS (if you have configured IIS) is located to the right directory (where your project builds the output), otherwise it can't start debugging either.
I've found a good hint (see my comment higher in this thread).
The WEBAPP have, as seen above, an _dll path.
This _dll path are there because this project has dll files shared with other projects. This means save space and don't have copies of same files for several projects.
Though,
This raise problems beause the webapp still are output/copy files to it's own sub bin/ directory. And even worse, not ALL needed dlls, which make error when the running web project (due to missing xxWeb.dll, which copies to _dll bin).
Accepting the fact to use standard bin/ fixed the problem this time. Why? The answer on that will not be in this thread, sorry. Someone with an idea would course make a comment here. In general, this isn't a drawback because the webb project binaries should be at the end of reference tree..
Open Visual Studio Command Prompt
and Run devenv /resetsettings

compile and publish only one .cs file

i have a Visual studio project. it has .aspx, .aspx.cs, config, dlls and so on...
Regularly what i follow for loading a gui on the server is:
build the solution
publish the solution (so i get the published files of the project excluding .cs files) this makes sense as i dont want to give my backend code.
finally i run the gui on the browser.
This works perfectly fine.
But now i have to make a change in .cs file of one of the pages.
do i have to build the solution and publish all the files?? how can i just give the file i made the changes in.
I ask this because it does not look good to a client...
any suggestions?? thanks
If you make a code change you should republish the site. Bear in mind that you can just publish the newly compiled assembly itself and not all of the aspx files.
However, I don't recommend doing this as the time to deploy an entire site isn't particularly large and you might have made a change to an aspx and forgotten between deployments. It's much better to send the whole thing.
Also, this isn't a normal thing for a client to have a problem with. Tell the client this helps ensure robustness of the deployment. After all, if you made a code change in a language like PHP and deployed that single file then you don't get compile time checking and stupid problems like misnamed variables might not show up for awhile or might crater the whole site.
IMHO, it's much better to get the full compile time checks out of the way BEFORE the site is pushed. Of course, this does little to nothing for runtime problems.. but that's a problem you have no matter the language.
C# doesn't have .obj and linker like c++, so if you change one file and want to integrate it in your project, you should compile it in related project (just changed files going to be compiled), also for file compile option see this: http://msdn.microsoft.com/en-us/library/78f4aasd%28VS.80%29.aspx

Categories