The compiler failed with error code 1073741502

This is a fun error you may never see while working on a Windows Server. I came across the other day when I arrived at work and unfortunately I still can’t pinpoint what caused it to happen but I can talk about what I researched and what we ended up having to do to fix it.

We had a couple sites on our development server (thank goodness it wasn’t live) that started producing this error. The obvious first steps were to do things like recycle the application pool, restart the site, and even restart IIS. Some reports from people online said that this fixed their problem.

Alas I was not so lucky. The next step was to venture into┬áC:\Windows\Microsoft.NET\Framework\ and into the appropriate framework and then into the “Temporary ASP.NET Files” and clear this folder out. In this case the sites were all running on .NET Framework v2.0.50727 but it is safe to clear out this folder anyways. The files that reside in here are just the compiled files being served up to the end-user and if they don’t exist, they are simple recompiled and served up fresh!

At first I just deleted the files being referenced in my specific error but when that didn’t fix, I just cleared the folder. Definitely not something I would do on a production server in case what happened actually happens. After I did clear out the entire temporary folder none of the sited would load and I was getting the 1073741502 error across the board.

Terrible, but it did offer a clue. None of the sites could be recompiled. Some more searching suggested that the Identity in IIS might not have sufficient permissions to run the compiler. A good thought but since this wasn’t a new server and I know it had been compiling that this wasn’t the problem (though I checked anyways for the sake of being thorough).

I then went and checked csc.exe, which happened to be the C# Compiler. Wouldn’t you know it, Windows was reporting that the file was 0 bytes in size. Ultimately we ran the .Net repair tool because it seems that our installation became corrupted. After this finished the sites worked fine, everything recompiled, and all was right in the world again.

Doing follow-ups, some people reported different ideas of what could cause it and the most prevalent one was possible hardware failing. As this is our development server only and not our back-up or production server it doesn’t always have the shiniest of hardware. We ran a back-up of everything just in case and the problem will be further investigated by the powers that be.

So if you ever come across a 1073741502 error:

  1. Restart the website in IIS
  2. Recycle the Application Pool
  3. Restart IIS
  4. Try deleting the files within the Temporary ASP.NET Files folder
  5. Be sure that if you are using a custom identity that it has proper permissions to run things like csc.exe
  6. Check for signs of a corrupted installation (files with no size, etc)

There are probably more effective ways to check this information but solid suggestions about how to handle this error were few and far between so it made for an eventful morning!

Quick Tutorial on using Session Variables

This is a down and dirty lesson on how to use Session Variables in C#. It won’t take long in your programming life that you will want an easy way to pass data from one page to another. Instead of using query strings (which also have their place in the world) or other methods, we can use these variables.

In your code behind file, wherever you want to add to the current session, you can simple add the line:

Session["yourVariableName"] = valueOfYourVariable; 

The “valueOfYourVariable” can pretty much be whatever you want. Strings, integers, variables, and so many other kinds of data.

On the page that is going to receive the data, pulling that information is as simple as using the following code:

string loadedData = (string)Session["yourVariableName"];

Obviously you need to cast your variable on the receiving page as the same data type as you saved it on the previous page, but other than that, it really is that simple to pass data between pages.

Any other complex data types you would just treat as you would normally once you load them.

 

behemothdan and son

Welcome!

behemothdan and son My name is Daniel and I am web designer and developer. My normal job involves a lot of C# and VB programming in a .NET environment with some classic ASP maintenance here and there. On the side, I do a lot of work in PHP and WordPress.

This site is all about coding, server maintenance, and problem solving issues that I come across in my day-to-day life. For more information, be sure to check out the About page.