HttpWebRequest throws “The specified registry key does not exist.”
Encountered a strange issue today, upon executing the following line of code, a “The specified registry key does not exist.” error was thrown.
A little googling reveals that the cause was a windows security update that was rolled out at work: MS12-074
1 | HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(url); |
Here’s a quote from the Microsoft KB article;
To enable the legacy functionality of WPAD, create the LegacyWPADSupport value in the following registry subkey:
Registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
DWORD (32-bit) Value name: LegacyWPADSupport
Value data: 1
Claiming back SQL Log space
I recently had the problem where one of our staging database servers had run out of disk space It contained about 40 databases, each of which was set to Full Recovery mode.
The maintenance jobs had been turned off which meant the log files of each of the databases had grown (the average was a 6gb log) I needed a way to claim back this disk space and without too much effort, and with no regard to what was in the logs. Here’s what i came up with.
It iterates through all databases on an instance of SQL,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | CREATE TABLE #tmpDatabases ( RowID INT IDENTITY(1, 1), [dbId] INT, dbName VARCHAR(255), recoveryModel INT, ldfName VARCHAR(255), oldLdfSize INT, newLdfSize INT, mdfName VARCHAR(255), mdfSize INT ) INSERT INTO #tmpDatabases SELECT d.database_id, d.name, d.recovery_model, ldf.name [LdfName], ldf.SIZE [LdfSize], 0, mdf.name [MdfName], mdf.SIZE [MdfSize] FROM sys.DATABASES d INNER JOIN sys.sysaltfiles ldf ON d.database_id = ldf.dbid AND ldf.filename LIKE '%ldf' INNER JOIN sys.sysaltfiles mdf ON d.database_id = mdf.dbid AND mdf.filename LIKE '%mdf' WHERE d.database_id>4 --only user databases DECLARE @RecoveryModel INT, @DbName VARCHAR(255), @DbId INT, @LdfName VARCHAR(255), @SQLUse nvarchar(1024), @NumberRecords INT, @RowCount INT -- Get the number of records in the temporary table SET @NumberRecords = @@ROWCOUNT SET @RowCount = 1 WHILE @RowCount 3 BEGIN SET @SQLUse = 'ALTER DATABASE ' + @DbName + ' SET RECOVERY SIMPLE WITH NO_WAIT; ' EXEC sp_executesql @SQLUse END --Shrink log file SET @SQLUse = 'USE ' + @DbName + '; SELECT DB_NAME() [Current Db]; CHECKPOINT; DBCC SHRINKFILE(' + @LdfName + ', 50); ' EXEC sp_executesql @SQLUse --get new log file size UPDATE #tmpDatabases SET newLdfSize = ldf.SIZE FROM #tmpDatabases INNER JOIN sys.sysaltfiles ldf ON #tmpDatabases.[dbid] = ldf.dbid AND ldf.filename LIKE '%ldf' WHERE #tmpDatabases.[dbId] = @DbId --output progress SELECT * FROM #tmpDatabases WHERE #tmpDatabases.[dbId] = @DbId SET @RowCount = @RowCount + 1 END SELECT *, oldLdfSize-newLdfSize [LdfDiff] FROM #tmpDatabases ORDER BY oldLdfSize-newLdfSize DESC DROP TABLE #tmpDatabases |
Installshield LE for Visual Studio 2012 : x64 support
When Microsoft released Visual Studio 2012 on the 16th of August 2012, I was disappointed to learn that they had removed support for the Setup and Deployment project types.
InstallShield Limited Edition (ISLE) is free for Visual Studio developers and replaces the functionality of the project templates in Visual Studio for setup and deployment.
Fortunately you can still open an VS2012 solution files with VS2010, and continue to use the Setup and Deployment functionality from there. However you’ll have problems when the applications/assemblies you want to package are using .NET 4.5 as VS2010 will not support those projects.
This left me in a bit of a pickle as i’d pushed the .NET version to 4.5, which left me the option of using Installshield Limited Edition for Visual Studio. However the version on the Installshield website was labelled as targeting Visual Studio 11. Proceeding to download it, and install it revealed it didn’t work with VS2012 at all. Thankfully last week I stumbled across a blog announcing SP1 to Installshield 2012, and the Installshield LE for Visual Studio has also been updated to support Visual Studio 2012 RTM.
Downloaded, installed and it works!! Woo hoo. The Installshield UI has been crammed into the Visual Studio IDE, but it works well. Instead of disabling options you can’t use, they’ve left them enabled with the a “sales pitch” screen appearing when you click on them (fair enough).
I created the installer for my windows service pretty quickly, built it and noticed that it wanted to deploy to C:\program files (x86) and not my usual C:\program files directory. After a little googling, it seems that the Limited Edition is just that, and x64 installations are not supported.
Workaround?
The usual predefined folder of ProgramFiles64 is not present, and when you try to install to [WindowsVolume]Program files it gets corrected to [WindowsVolume]Program files (x86). As installscript is disabled in Installshield 2012 LE, i can’t do much else to fool it. The good news is that because it’s just a file copy that Installshield is doing and my assemblies are set to Any Cpu they still run as x64 processes.
It’s not just the file copying that’s affected by Installshield 2012 not having “Enhanced 64-bit application support”, registry entries are put into the Wow6432Node part of the registry. Registry settings being in the wrong location is something that i can handle in my code… (that’s another blog post).
I did look at trying to leverage the Visual Studio ClickOnce deployment to deploy my windows service, but it’s not really doable for the following reason;
ClickOnce does not support custom destination folders. The reason why ClickOnce-deployed applications are installed into the cache is that such cache is maintained by the .NET Framework, which is responsible for executing applications deployed via ClickOnce.
Ref: http://social.msdn.microsoft.com/Forums/en-US/vbide/thread/997a0b71-3af7-49e8-9d8d-2b23655fa4d3
So what’s the solution?
If you don’t care about the fact that the files get installed to the x86 program files folder and you can fix any other issues in your app then use Installshield 2012 LE.
If you don’t mind using VS2010 and you are using .NET4 or below then that’ll still work.
Otherwise unless you want to roll your own solution, you’ll have to use a separate installation program such as Installshield 2012 Pro.
Google Chrome – Kerberos, Delegation, Negotiation, Auth
One of my more recent jobs was setting up a webservice that is both separated from the web application box and in need of the windows credentials of the original caller. After discovering a lot of the pain around SPN’s and kerberos where I found myself bound to internet explorer, I was really keen to get it working in my browser of choice.
(I’m using Windows 7 and my web applications are on a windows domain).
There is the mention of various websites of using the parameter –auth-negotiate-delegate-whitelist when starting Chrome..
This never worked for me.
What did work is documented here http://dev.chromium.org/administrators/policy-list-3#AuthNegotiateDelegateWhitelist
Basically, just adding a registry entry to specify your whitelist of servers.
1 2 3 4 | Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome] "AuthNegotiateDelegateWhitelist"="myserver,myotherserver,*.mydomain.local" |
What the document doesn’t tell you is that after making the registry change, you have to reboot for the change to take effect, just by exiting chrome or killing the chrome process won’t cut it. After making the change, close Chrome and ensure you kill any of the resident Chrome processes with task manager.
WCF Configuration Pt1 : SSL and Windows Authentication
WCF isn’t the easiest beast to wrangle, and when looking to secure a WCF web service I usually do it in stages.
In this post and further posts in the next week, I’ll be securing a WCF web service with various endpoints with various different security requirements. To start with I’m just going to secure it with Windows authentication and SSL.
It always seems to take a little fiddling to get to the first stage, published in IIS using SSL and Windows Authentication whilst still functioning.
Once IIS has been configured
- Website created
- Single HTTPS binding
- SSL Settings (Require) (Ignore client certificates)
The next step is to get the webconfig to work over SSL and to use windows authentication.
1 2 3 4 5 | <behavior name="basicSSLServiceBehaviour"> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483646" /> </behavior> |
1 2 3 4 5 6 | <binding name="SimpleWinAuth" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000"> <readerQuotas maxStringContentLength="6553600" maxArrayLength="6553600"/> <security mode="Transport"> <transport clientCredentialType="Windows"></transport> </security> </binding> |
And the endpoint config will look something like this;
1 2 3 4 5 6 | <service behaviorConfiguration="basicSSLServiceBehaviour" name="MyCompany.MyApp.Services.SomeNameOrAnother"> <endpoint binding="wsHttpBinding" contract="MyCompany.MyApp.Services.ISomeNameOrAnother" bindingConfiguration="SimpleWinAuth" /> </service> |
So there you go, simple configuration to use enforce SSL and Windows Authentication in WCF.
Are certifications worth the paper they’re printed on?
I seem to often be having the discussion these days about Microsoft Certification, and it’s actual value. Having worked with the Microsoft stack of development and server technologies for over 12 years I’ve got a lot of proven experience with products like SQL Server and Visual Studio so why bother taking the exams if it’s evident I know the product/technology well??
I don’t view experience and exams as mutually exclusive, in fact since the exams normally heavily emphasise the new features in that version it shows you have a breadth of knowledge in that area. Too many developers stick to what they know and don’t make use of the advances in technology, the VBA developer brings with him the “on error resume next” / “goto” mistakes of the past up to .NET.
However, taking exams with little prior knowledge of the subject areas or professional experience in that area isn’t a quick route to success. It’ll put you on the right track, but just because you have your MCPD it doesn’t make you better than the guy sat next to you with a careers worth of experience.
Certification shows a desire to learn, there were a few topics i learnt about whilst studying for my 70-515 .NET4 Web exam that I haven’t ever spent anytime on. Theming and skinning being on of those, I’ve never bothered using it and CSS has always been good to me… But at least I understand what it is and why I’m choosing not to use it.
I’ll end this exploration into my opinions here, and will be sure to post again when I get my MCPD badge and gun.
Resetting the admin password of a Visual Sourcesafe database
I stumbled across an old visual studio database at work that was inaccessible.
After finding a couple of Visual Sourcesafe crack applications, i settled on doing it manually with a hex editor (HxD Hex Editor).
Find the sourcesafe database in windows explorer, open the data directory and open um.dat.
Changing to the values highlighted in red reset the Admin password to an empty string.
Crappy Code Games
In May, the SQL Server conference SQLBits 8 took place in Brighton. Fusion-IO had sponsored the event and had initiated the first Crappy Code Games event. This consisted of 4 challenges designed to flex the IO of the Fusion-IO drives.
Prior to the Crappy Code Games final in Brighton there were 2 previous warm up events in Manchester and London, I attended the London event and entered one of the challenges; “Maximum number of transactions in a minute” and came third bagging myself a podium place and a Winmo phone.
Then came the final, which I actually couldn’t attend. I left a revised script file with @mdknee who entered it under my name, and later that night received a few tweets from the Fusion-IO representatives from the event.
Somehow, I’d managed to bag first prize which was a flight experience with 2 high performance aircraft.
Here’s a pic of me being presented with the award by Steve Woziak (I’m the piece of paper
)
And some links where i’m name checked
http://www.fusionio.com/news/press-releases/fusion-io-crappy-code-games-winners-flush-with-sql-achievements/
http://www.fusionio.com/blog/top-sql-dbas-flush-away-crappy-code-in-brighton/
http://www.fusionio.com/blog/sql-warriors-compete-for-honors-in-londons-crappy-code-games/
Powershell function to add script to the profile
I’m currently in the middle of learning powershell; More specifically, on day 4 of the Microsoft 10325a Automating Administration with Windows Powershell 2.0.
With my coding background, i’ve tended to write most of the script inside functions to try and promote reuse. I’ve found that maintaining a library of functions to be a bit of a headache so ended up writing the function below. It’s by no means perfect (lets face it, PoSH is a little new to me currently… lets see how long before v2 makes it onto my blog), but it does the job.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | function Add-CodeToProfile() { <# .Synopsis Adds a code snippet to your PoSH user profile .Description Ideally, you will want to add whole functions, not just one line scripts. .PARAMETER Scriptblock A block of script that you want to save for future reuse .PARAMETER FileName If specified, a file will be created to store the script in. #> PARAM ( [Parameter(Mandatory=$true)][string]$Scriptblock, [string]$FileName ) [string]$usersProfilePSdir = "$env:userprofile\My Documents\windowspowershell\v1.0\"; [string]$usersProfilePS1 = $usersProfilePSdir + 'profile.ps1'; if(-not(Test-Path "$env:userprofile\My Documents\windowspowershell")) {new-item "$env:userprofile\My Documents\windowspowershell" -type directory} if(-not(Test-Path "$env:userprofile\My Documents\windowspowershell\v1.0")) {new-item "$env:userprofile\My Documents\windowspowershell\v1.0" -type directory} if(-not(Test-Path $usersProfilePSdir)) { #Add PS1 new-item $usersProfilePSdir -type file } else { #Add a line break at the end of the file "`r`n" >> $usersProfilePS1; } #check filename if ($fileName -eq "") { #Add function to users profile $Scriptblock >> $usersProfilePS1 } else { #Add function to new file $newScriptFile = $usersProfilePSdir + $fileName + '.ps1'; $Scriptblock >> $newScriptFile; #Add reference to profile '"' + $newScriptFile + '"' >> $usersProfilePS1 } } |
MIUI Android – Tasker Volume interaction problems

Having recently started putting community rom’s onto my Motorola Defy (tinkered with CyanogenMod and LiquidArc), I got a bit fed up with the LiquidArc rom and fancied a change; Queue the MIUI android rom.
I’m not going to go into the virtues of the rom, but needless to say it’s put my ICS angst on hold.
One issue i did come across was that Tasker wasn’t quite working correctly. Whenever it came to change the system volumes the correct changes never got applied. After googling it, there’s a few suggestions to change the “Third Party Access” setting in the call settings. However in version 1.11.18 this setting doesn’t appear.
The correct solution is that the version of Superuser in the rom is particularly keen to deny the AllowPhone state permission. All of the other versions of superuser that i’ve seen only control access to applications that specifically request root access. This version doesn’t seem to have that limitation.Explicitly allowing Tasker to “Monitor Calls” means that it’ll once again be able to control the volumes.
My Blog
Stack Overflow
My Recent Tweets
Error: Twitter did not respond. Please wait a few minutes and refresh this page.






