MichaelDev
Monday, December 13, 2004
  Some things that slowed me down today...
I've been working on a web service and ran into two things that messed me up today. My web service was working fine all along; it was just the code behind doing some things wasn't.

Problem #1: Strong Name Identity Permission
I've been reading a little more about RUP and have taken some of its recommendations to heart. So, in developing this web service, we're tackling the risky and difficult things first. In this case, it's making sure the web service works properly and can return the necessary information. We're also trying out deployment scenarios now to make sure we really can deploy and install the thing as we intend. This involves fun with the DNS and Windows Installer (we're using Wise for the installer).

So, our little web service merely grabs and Xml file and returns it. When it's all done, it will grab stuff from the database, etc. However, for now, the Xml works great. We can work on our bigger risks. Getting the real return stuff out of the database for the web service to return is a triviality.

The basics of the web service were working fine. Now I needed to add encryption. We have some company framework code, and one of the classes takes care of encryption. When I added in this code, the web service stopped working.

This was driving me nuts. Unfortunately, I was trying to debug this with just running the web page that comes up when you go to the .asmx page. It seemed simple enough. But I was now getting errors.

I finally went back to the test app I had written and decided to try communicating with the web service from it. This proved very helpful. Now I got a real exception back from the web service and could see what was wrong: I was getting a security exception. One look at it and I knew what I had forgotten to do. We use Strong Name Identity Permission on our framework code (I should know; I put most of it there). Well, I had forgotten to add the AssemblyKeyNameAttribute to the AssemblyInfo file. Once I put this in the new project, everything worked like it should. I wish I'd solved the problem a little sooner, but the good news is that I solved it!

Problem #2: XmlTextReader
While experimenting with the above, I changed some text in the Xml file that was being returned by the web service. One time I did something that wasn't good Xml. When I used the XmlTextReader to load it into an XmlDocument, it threw an exception. Of course, this made it pass over calling the XmlTextReader.Close() method. This turns out to not be a good thing!

If Close is not called, the operating system will still think that an application is accessing the file, even if the XmlTextReader class goes out of scope and even if the application that called it shuts down! I could not now edit my Xml file to fix the problem I had introduced.

With a quick fix of the code (putting the Close in a finally block), I ran it again and got the error, but at least this time the file was closed so I could now modify it (or delete it). It was a heck of a lot faster than rebooting!
 
Comments: Post a Comment



<< Home
Various notes on software development. Currently using C# and .Net. May also include comments on the overall software development process, etc.

Name:
Location: Orange County, California, United States
ARCHIVES
June 2004 / July 2004 / August 2004 / September 2004 / October 2004 / November 2004 / December 2004 / January 2005 / February 2005 / March 2005 / April 2005 / May 2005 / September 2005 / October 2005 / November 2005 / January 2006 / February 2006 / April 2006 / May 2006 / June 2006 / March 2007 /


Powered by Blogger