Sunday, February 10, 2008

Temp directories

Sometimes you just need a temp directory to store stuff in. Pre-Vista this was easy; System.IO.Path.GetTempPath() however, like the documentation says, this is the System's temporary directory, not yours so it does not work so well in Vista.

I do not know what the BEST solution is but this seems to work well:

System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)

..and there a slim chance that any non-deleted temp file will occasionally get cleaned up too.


 


 


 


 

When is an Administrator not an Administrator

I am attempting to get a little in house command line maintenance utility working tonight on a new Vista 64 machine.

The program appeared to be having some problems accessing a temp directory; more on that later. So I opened up VS 2008. Not really knowing what type of debugging I would be doing to solve the problem, I chose to run it as an Administrator.

The program needs to access a network drive in order to copy over some backup files. The program was returning false on Folder.Exists() call!?!?!

A bit of searching later I discover that under Vista and VS when it is run as an Administrator any network drives are automatically disconnected. The trick is to either 'activate' the network drives by simply navigating to one by attempting to open a file or the like.

Fortunately if you exit VS and run it again as an Administrator it will remember the connection. I have not tested it after a reboot though.

Interesting, if you run VS not as an Administrator then you do not have the problem.

Very annoying.

The problem with KPIs

The Silverlight team proudly proclaim that the installation experience of Silverlight should be very simply and very short; 20 secs from the download to installation complete.

Hrmm.... on my laptop, after 2 min I lost interest. Fortunately after I returned from putting the kids to bed it was finished.

I checked out some of the examples on the community gallery site; It really makes you aware of how immature the technology is at the moment.

Having said that I am really excited about Silverlight. In time it should be great.


 

Saturday, February 09, 2008

Frustrations upgrading from VS2003 to VS2008

I have just upgraded one of my major projects from VS2003(!) ASP.NET to VS2008 Web Application Project. It went relatively well. One must remember to right click on the project and select 'Convert to Web Application' otherwise the designer.cs files are not created for the web pages.

When it was released it was throwing the following:

The type 'tcpIQ.Web.WebSite.LineSpeedMeter.Api.Soap.V401111.LsmSoapApi' is ambiguous: it could come from assembly 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\100c9fe3\aa17ce8c\App_Code.d11yv5mk.DLL' or from assembly 'C:\Inetpub\wwwroot\tcpiq.com\wwwroot\bin\TcpIQ.com.DLL'. Please specify the assembly explicitly in the type name.

There are lots of chatter about this exception and it appears that it can occur for a number of different reasons. In my case it was because in the conversion from 2003 to 2008 an 'App_Code' directory was created and some classes were placed in there. Files in this directory are dynamically compiled at run time and the DLLs are stored in the Temporary ASP.NET folder as opposed to the bin folder. Needless to say this trips up ASP.NET since it can see two different assemblies for the same class. The solution was to simply migrate the classes back out of the APP_Code folder and place them somewhere more suitable, recompile, re-release, recycle and it worked!


 

Wednesday, February 06, 2008

Vista x64 - "the disk is write-protected"!?

I am the proud owner of a new Vista x64 8GB machine.

After a reboot this morning SQL Server had declared that all of my databases were suspect. After a bit of scratching around I discovered that my D:\ (RAID 10) where all of my data lives had become read only. This was not a permissions problem as it was working before the reboot. I rebooted and it was still the same.

After a bit of googling and reading between the lines I rebooted, pulled the power, went for a coffee, read the paper, powered it back up and it started working again.

For the record you may see ""the disk is write-protected" or "the media is write protected". Also, Vista SP1 has just gone to RTM so it is not installed but otherwise the computer is fully patched.