Your browser does not have JavaScript enabled. JavaScript is used to enhance both BitLeap’s website and our Customer Control Panel. You may not be able to use all the functions of our website properly with JavaScript disabled. Sorry for any inconvenience this may have caused.

Loading Data...


Delay While Creating X509Certificate2 Objects

While developing in Visual Studio 2005 we ran into a problem where sometimes there would be a long pause (about 10 seconds) during the creation of X509Certificate2 objects. Yesterday we decided to dedicate some time to figure out the root cause of the issue.

The first thing we did was create some breaks around the code so we could step through it and then we started filemon to monitor the file system activity. Right away we noticed something odd, there were a bunch of log entries for files named C:\Documents and Settings\[Your User Name]\Local Settings\Temp\Tmp[0000-ffff].tmp. We opened the folder that contained the files and found that there were over 66,000 files in the directory. We also noticed that there were files named Tmp0000.tmp all the way up to Tmpffff.tmp. We decided to remove all of these files to see if that may fix the issue. Sure enough after removing the files the long delay was gone.

Even though the delay was gone, we wanted to find out why there were so many temporary files in the first place. So we stopped the application in Visual Studio and switched back over to Explorer to see if there were any new temporary files. Sure enough there were two new files that were not cleaned up. We removed the files and then started the application again and stepped through the code in the suspect area. Sure enough when creating the new X509Certificate2 object, two temporary files were created and not removed. We went over to the MSDN site to make sure we were not missing a cleanup call or something that would remove the files, but we could not find any such method.

However, we did notice that you can pass a file path rather than a byte array when constructing the object. This led us to our workaround for the issue. We simply created a temporary file and wrote the bytes to it. We then passed the temporary file path when constructing the new object. After the object was created we removed the temporary file.

With all this information we thought it would be nice to provide it to Microsoft so that they could research it. We did just that by heading over to Microsoft Connect and creating issue #284551 and issue #284553.

One Trackback/Pingback

  1. […] Microsoft? It isn’t easy, as I found out when I reported an issue we found that was causing a delay while creating X509Certificate2 objects in the dotnet […]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*


 

BitLeap Devblog

Welcome to the BitLeap developer blog! Some posts are longer than others, but they all seem to make use of links and code and stuff. Feel free to read, or not to read, as you so desire and prefer.