IndyALT.NET Site is live!


IndyALT.NET is now live!

Right now it’s being hosted in somebody’s house (thx to Paul Hacker, MSMVP, for sharing his servers temporarily!) We’re excited about our first two events! Next month we’re having Mike Griffin come in for some training on the EntitySpaces OR Mapper. In July we are planning on having Todd Anglin come in and show us some good stuff with some of Telerik’s products. And who knows what else we’re going to do!

Interesting and busy times to come!

-Shane



Automatic Generation of API Documentation for .NET 2.0 Code


I was recently given the task to generate some API documentation for all of the code on a project I was working on (11 different projects, 3 different solutions) so I began looking into what was available. I remember using NDoc with old 1.1 projects, but that project was apparently abandanded. Microsoft has an October 2007 CTP release for a replacement called Sandcastle. It’s a suite of files that provide the core functionality of generating HTML and CHM files for documentation in an MSDN-like style. Apparently, this is what Microsoft uses internally to generate their MSDN documentation.

Unfortunately, Sandcastle comes with no GUI to use it but fortunately, there are several free GUIs written out there to do it for you. To find out more about it, I thought this site was most helpful.

-Shane



Visual Studio 2005 Deployment Projects on Vista – Error #2869


I found this blog posting that finally solved a problem that was by no means obvious to me!

http://msmvps.com/blogs/kevinmcneish/archive/2007/05/09/fixing-the-cre…



.NET 2.0 Simultaneous Web Service Calls give “The request was aborted: The request was canceled.” error


We’ve been having web requests just randomly fail with an error message of “The request was aborted: The request was canceled.” Simple testing would never produce this result yet real-world use and stress testing would indeed cause this problem. If you Google it and you’ll find many other people with this exact same problem. But finding the actual reason for the problem is a bit more difficult. Luckily somebody (birch9397) opened a ticket with Microsoft and shared it, which hit the nail dead-on at the Microsoft Forums. Here is a snippet that contains the beef of the source of the problem:

It turns out that when you start to make spin up your second set of threads to call the remote web service your ASP.NET application is waiting for a response from the web service but instead the web server resets the connection. Within the dump that I collected we see that there is an exception with the text of “The underlying connection was closed: A connection that was expected to be kept alive was closed by the server”. It appears that the code logic in .NET 2.0 is that when this occurs we will try to resend the web request, however because of the previous exception the m_Aborted property of the HttpWebRequest object is set to true and so we end up getting the Request Canceled exception that you are seeing.

For our next troubleshooting steps I’d like for you to disable Http KeepAlives for the HttpWebRequest object in your .NET 2.0 application. This will force the client to establish another TCP session with the BEA Web server before sending out another web service requests.

In order to set the KeepAlive property of the HttpWebRequest object to false you will need to override the GetWebRequest method within your client application. Please see Resolution D in the following article to see how to do this in your ASPX client page

915599 You receive one or more error messages when you try to make an HTTP request in an application that is built on the .NET Framework 1.1 Service Pack 1

http://support.microsoft.com/default.aspx?scid=kb;EN-US;915599

Luckily, a user there named Antzone gives a simple code snippet showing you how you can resolve this issue for yourself. If you create a wrapper class around your base WebRequest class, you can override the GetWebRequest(Uri) method and set the HttpWebRequest.KeepAlive propert to false in just a couple lines of code. Then everywhere you instantiate your webrequest, simply instantiate this new web request instead.

Not bad and makes many errors go away! :)

-Jax



Losing connections due to ADO.NET bug using Transactions


Environment: ASP.NET 2.0/C#/SQL Server 2005 (SP1 on live servers and SP2 on some development and test servers)

So we’ve been developing an application for many months and finally went live with it. Once going live, seemingly randomly we started getting the following problem:

Fill: SelectCommand.Connection property has not been initialized.
Exception Details: System.InvalidOperationException: Fill: SelectCommand.Connection property has not been initialized.

Once we got this, we remembered seeing it somewhat unpredictably during development:

<backflash>
We were using the MyGenerations OR Mapper for our data tier. This is an open source product so we were compiling it in release mode on our own then just pointing to the DLL. Because it was open source, one of us added the MyGenerations project to our solution to debug the problem, but doing so made the problem go away. We ended up adopting this as a workaround to this problem so we could move on (mistake #1).

Just before deploying our application to the live servers, we had a conversion application that was written to convert data from the legacy system to the new system. Everything worked fine until we tried doing the true conversion – we had this same problem. Somebody stumbled upon a workaround by simply running the conversion utility in debug mode and this worked. Because all systems were down and this conversion tool was a 1-run program before it got thrown away, this was an acceptable solution. However, nobody looked further into the problem (mistake #2).
</backflash>

So now back to the present day. Once going live, it seemed every couple days we’d get this problem. Once this problem occurred, ALL connections (it seemed) were hosed and the entire site was down until we did an IISReset. Because it happened so infrequently and we had no clue how to reproduce it, we just monitored the situation with this defect (while working on many other defects). Over a period of a couple weeks, this problem grew and grew until it was happening 10 times a day (again, we didn’t know how to reproduce it but we were logging the hell out of things from every angle we could think of).

Oh, and one more thing – our database is being hit by 3 independent web sites/servers and they were only going down 1-at-a-time so it was most likely not any issue with the database server itself.

Now the obvious first guess at the problem was that we weren’t closing our connections and the connection pool was running out of them or perhaps we had hanging transactions that were causing problems, or something along those lines. We code reviewed the MyGenerations code up and down, left and right to no avail. Then we started reviewing tons of our code, again, no luck. However, one thing we did learn was that simply doing nothing other than compiling the solution in debug mode made the problem go away!

We finally opened a ticket with Microsoft. After a couple weeks of working with them and one of our guys stumbling upon this post, we finally came to the source of the problem – a bug in .NET 2.0′s ADO.NET. Before I show you the fix, read this snippet from an email from Microsoft after we fixed it that explains the problem at a high level:

Based on your information, I did locate a bug on this. The development team does not have any plans right now for a hot fix, but they are looking at fixing this in the future as the forum post indicates. The issue only occurs when you use the transaction as the sole (or last) reference to the connection. Then there is a brief window when the transaction only has a weak reference to the connection and if a Garbage Collection occurs before it is converted to a strong reference, then it will collect the connection object. The reason it doesn’t show the problem in the debug build is that variables are not freed as early as they are when an application is compiled for Release mode, and so we delay enough the window is a non issue. The workaround is fairly simple once you understand the nature of the problem and that is to keep an external reference to the connection that is outside the transaction object.

So the fix was just as he said it was, keep an external reference to the connection that is outside the transaction object. So in our case, with the help of the MyGenerations developers, we modified the MyGenerations code to do this and our problem is gone, at last! So expect an update to their software very soon to work around this .NET bug. And if you hit this problem with your own code, now you know how to fix it. :)

-Jax


Jaxidian Update is proudly powered by WordPress and themed by Mukkamu