#Google Analytic Tracker

Pages

May 8, 2008

No files were found to look in. use Ctrl+Scroll Lock!

 

Credit goes to: http://blogs.ugidotnet.org/franny/archive/2005/12/08/31303.aspx

Today, one of my colleges ran into a problem. He click on "Ctrl + Shift + F" to open the Find and Replace dialogue, and he tried to find a string in his solution.

image 

The text that he wants to search is right in front of his eyes, yet clicking on the Find All button only returns: "No files were found to look in.Find was stopped in progress."

He thought that he must be tired today.  Double check his spelling, his cap lock, and all other options. There it goes his 1/2 hr of work.  So, he came over to me to make sure that ensure that he is not hallucinating.  I said no, surely something is wrong with VS.

Another one of my colleges overheard our conversation, and said, "Try Ctrl + Scroll Lock".  WT..., how does Ctrl + Scroll Lock helps to solve this issue? Surprisingly, it worked!

The annoying part is that there is no explanation on how you get into to this state and how to fix it.  Obviously, no one will spend time continue investigate into this, because your main job is to develop your product and not debugging your development tools.

I suspect this maybe due some incorrect interaction between Visual Studio and the OS layer. The Scroll Lock button is rarely being used in modern software. In the past, when people still uses text-based UI, this button is used to make the arrow key to scroll the contents of the text window instead of moving the cursor.

Apr 8, 2008

Process cannot access the file! Please close your XmlReader!

At work, we have many scripts and utility programs to aid us in testing and developing our product.

After upgraded to VS 2008, I notice that one of utilities that I run regularly no longer working.

Here is the error that I got:

The process cannot access the file 'c:\xxx\yyy.xml' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, Fil
eOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.Xml.XmlDocument.Save(String filename)
   at GenRes.GenRes.Main(String[] args) in C:\xxx\GenRes.cs:line 191

I asked all my colleges, and they don't have any problem running this utility.

Struggling with the fact why my computer doesn't run the utility properly, I start debugging line by line in VS.

Looking into the GenRes.cs file, it is what it tries to do.

// Load Data to XmlDocument
XmlDocument xmlStringsdoc = new XmlDocument();
xmlStringsdoc.Load(XmlReader.Create(args[0] + ".xml", settings));
//...
// Save Data back to the xml file
xmlStringsdoc.Save(args[0] + ".xml");

Strangely, when I run the utility in the debugger, I don't get any error.

Not really sure why (which I hope I eventually find out), I decided to see if I can fix the code so that it will work on my machine, and hopefully it will works on others too.

By analyzing the code, most likely I get this error because XmlReader isn't close when xmlStringdoc try to save the data.

Looking into the revision of the file. I notice that one of my college changed the following:

//FROM xmlStringsdoc.Load(args[0] + ".xml"); // TO
settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
xmlStringsdoc.Load(XmlReader.Create(args[0] + ".xml", settings));

It turns out that we don't want to prohibit DTD when process the file.

Here is the simple fix

   1: XmlReader l_oXmlReader = XmlReader.Create(args[0] + ".xml", settings);
   2: xmlStringsdoc.Load(l_oXmlReader);
   3: // Close the reader since it is no longer needed
   4: l_oXmlReader.Close(); 

All I have done is CLOSE the reader! After testing the code, it works.

Here is the reminding questions I want to know:

  1. Does XmlDocument.Load(string) automatically close the file?
  2. Why this issue only happen on my machine and not others, is there some kind of  windows or .net framework setting?
  3. How can you write a unit test to ensure this utility work on all developers machine?
  4. How come I don't get an error when running the code in Debugger?
  5. Why does the error message say the file is being used by another process (but in fact, it is the same process that accessing it)?

Hopefully I can answer this question in the future.

Mar 16, 2008

Visual Studio Installation Strange Disk Space Requirement

Recently I attended "Hero Happen Here" event in Calgary, and obtained a copy of Visual Studio 2008 Standard Edition.  Similar to the Visual Studio 2005 lunch event, everyone get a copy of Visual Studio Standard edition. But since this is my first time attending such event, I was pretty excited that I got my own Visual Studio 2008.

After I got back home, I immediately uninstall my Visual Studio 2008 beta version.

Surprisingly, the first error that I encountered is not during VS installation (although I usually have faith that VS will install properly), but rather when I uninstall the beta.

"no disk Exception Processing Message c0000013 Parameters ...."

By doing a quick google search, I found this forum.  I recalled that I installed the beta from a external hard drive. I must have removed the VS 2008 installation file or changed the drive letter. My quick fix was to unplug my external hard drive, and uninstall the beta. But really, a software shouldn't need to check for disk during un-installation.

Anyhow, here is what strange about my VS 2008 installation experience. Notice my installation path is on C drive, but the Disk space requirements show that I need 204 MB on my E drive.

Strange VS Installation with Hightlight

My E drive only stores my media files like music. I never use this drive for program installation of virtual memory mapping.

After I installation, I checked my E drive and it doesn't seem to have any extra file installed. It would make more sense if it is D drive because this is where I store my user profile!