I have found the cause of the problem. It was some new security software that pushed out to all workstations by sys admin. I was unaware of this until someone said when I was using their workstation to test things, "hey could it be this new software thing that was pushed out recently".
I knew they were going to do something about thumb drives but I thought they were going to provide thumb drives that could be encrypted. This software affects everything removable. I have only just moved to a new workstation because of AD account lockouts so I thought it might be the workstation. When the software was uninstalled on my workstation, it worked as expected. Sys Admin are going to put in a support request to have the issue examined. Regards Peter Maddin Applications Development Officer PathWest Laboratory Medicine WA Phone : +618 9473 3944 Fax : +618 9473 3982 E-Mail : [email protected] The contents of this e-mail transmission outside of the WAGHS network are intended solely for the named recipient's), may be confidential, and may be privileged or otherwise protected from disclosure in the public interest. The use, reproduction, disclosure or distribution of the contents of this e-mail transmission by any person other than the named recipient(s) is prohibited. If you are not a named recipient please notify the sender immediately. From: [email protected] [mailto:[email protected]] On Behalf Of David Kean Sent: Tuesday, 18 May 2010 12:12 PM To: ozDotNet Cc: David Kean Subject: RE: DriveInfo.GetDrives() not returning I actually own this code - I'll have a look at this in the morning (Seattle time). ________________________________ From: [email protected] [[email protected]] on behalf of Maddin, Peter [[email protected]] Sent: Monday, May 17, 2010 8:53 PM To: [email protected] Subject: DriveInfo.GetDrives() not returning I am writing a simple application where users can import data from a file on a CD/DVD. To get a list of ready CD/DVD drives I am using this code /// <summary> /// Returns drives of specified type ~ and specified status. /// </summary> /// <param name="driveType">The type of drive one is primarily interested in</param> /// <returns> /// Drive designation of the first available drive for the specified DriveType or if none are ready, the /// drive designation of the drive where this assembly is being executed. /// </returns> private List<DriveInfo> GetDrivesOfType(DriveType driveType) { DriveInfo[] allDrives = DriveInfo.GetDrives(); var selectedDrives = new List<DriveInfo>(); // Look for first CD/DVD drive that is ready foreach (DriveInfo drive in allDrives) { if (drive.DriveType == driveType) if (drive.IsReady) { selectedDrives.Add(drive); // we only want the first ready CD/DVD drive break; } } // if there is no ready CD/DVD drive then get the drive info for // the drive where this assembly is executing. if (selectedDrives.Count == 0) selectedDrives.Add(new DriveInfo(Path.GetPathRoot(Assembly.GetExecutingAssembly().Location))); ; return selectedDrives; } When I first use this method, it works fine. When a user opens the drive, removes the CD/DVD, closes it again and waits for it to register the presence of new media, then as part of the process to read in a new file the method is called again. When called a second time, it hangs on DriveInfo[] allDrives = DriveInfo.GetDrives(); The actual application turn rogue. You cannot kill it off in windows task manager. If debugging in Vs2008, the debugger eventually detaches the process and one can start again. Is there any known reason why this sort of behaviour would occur? I moved DriveInfo[] allDrives = DriveInfo.GetDrives(); So its called only once, but then it hangs on if (drive.IsReady) I can't seem to do anything to address this problem. The DriveInfo class does not have anything that I can see t One solution I have had is to run this in a separate thread and it if does not respond, kill the thread. Ok that may deal with the hang-up but it still does not enable the user to open and process on the files on the CD/DVD media. I have googled on this and seen other with similar issues. One suggestion is that the DriveInfo[] allDrives = DriveInfo.GetDrives(); Will usually return after 30 seconds but may take up to 3 minutes. In my case it does not return at all. I am targeting .NET 3.5. Is it a framework problem, driver problem, some other problem? Could it just be the machine I am using? Anyone else experienced this sort of issue? Regards Peter Maddin Applications Development Officer PathWest Laboratory Medicine WA Phone : +618 9473 3944 Fax : +618 9473 3982 E-Mail : [email protected] The contents of this e-mail transmission outside of the WAGHS network are intended solely for the named recipient's), may be confidential, and may be privileged or otherwise protected from disclosure in the public interest. The use, reproduction, disclosure or distribution of the contents of this e-mail transmission by any person other than the named recipient(s) is prohibited. If you are not a named recipient please notify the sender immediately.
