Archive for August, 2014

Extracting a polygon from a SQL Geometry

So you’ve woken up in the night, screaming, because you can’t figure out how to extract a polygon from a SQL Geometry type, right? Yes, I feel your pain. But don’t worry – a very simple query using the STAsText method will put your mind at ease:

SELECT geometry::STGeomFromText(CONVERT(NVARCHAR(MAX),geometry),4326).STAsText() FROM States


Leave a comment

Copying a DLL from the GAC

I’m a little paranoid about upgrading DLLs in the GAC. Specifically, I want the existing version in case the version I am about to update goes horribly wrong. Upgrades gone wrong has probably never happened to you, but it has for me, and I want to be sure I can roll back a GAC update if the sad clown of life strikes. So when I needed to update the latest version of DukesOfHazzard.dll, I wanted to create a backup.

The GAC is in the C:\Windows\Assembly folder. If you navigate to that folder, you can’t just copy the file somewhere else. I’ve read on Stack Overflow about a modification to Windows Explorer, but frankly, I didn’t want to jump through hoops just to copy a file. So instead of jumping through those hoops, I jumped through different ones.

To copy a DLL from the GAC to another folder:

1) Open a command prompt.
2) Go to the c:\windows\assembly\GAC_MSIL folder.
3) Move into the directory of the DLL that needs to be changed. In my case, “cd DukesOfHazzard”.
5) Inside of the DukesOfHazzard folder is another folder with a wonderfully obtuse name, like 1.0gac.0.0__56da0244276eb35e. Move into that directory: “cd 1.0gac.0.0__56da0244276eb35e”.
5) Success! You have reached the folder where you DLL actually resides. Copy it to whatever awesome directory you want: “copy DukesOfHazzard.dll c:\ScottRocks”. It IS required to have a directory called ScottRocks, in case you were wondering.

Leave a comment