Tag: Windows
Using Windows Live Writer to publish this post
by bhartsock on Aug.22, 2009, under Uncategorized
I downloaded Windows Live Writer today and am using it to publish this post.
Why Live Writer and not the Wordpress interface? No real reason. The nice thing about live writer is I get the benefits of using a desktop app instead of a web app. It is faster, can work offline, and HTML editing is a bit easier (yes, I am a web developer but it is nice to work a layer above HTML sometimes).
Some of the really cool things are it is pulling almost all my data from Wordpress. All my categories, tags, settings are here, which is nice.
My only question is how is uploading this picture going to work? If you are reading this, you already know whether it worked or not, unfortunately, I have no clue what is going to happen.
Why UAC sucks?
by bhartsock on Mar.07, 2009, under Uncategorized
User Access Control is a good feature. Prohibiting implicit changes to administrative settings is good. Linux has done this for a long time with sudo. But Vista made a good thing annoying.
You have to click Ok every time instead of it realizing you know what your doing. Sudo can remember for a certain amount of time. Although I complain, I can actually live with this downside.
It is ugly and slow. I have a year old machine, that I think is fairly beefy. Even still, my entire screen turns black for a second while the UAC dialog loads. Very annoying.
Elevation is a pain. If I am running a program that needs to do administrative tasks, I usually have to restart. Yes, certain applications elevate easily, but Powershell and Visual Studio don’t. Why should I have to run them as an admin? Can’t I just elevate permissions as necessary?
I think that UAC solves a security problem but fails in the usability department. I love the concept. I love Vista. I haven’t had a chance to play with Windows 7, but I really hope they improve on some of these areas. Preventing malicious activity is a great thing, it just can’t hinder normal activity.
System.ArgumentOutOfRangeException at System.Web.HttpCachePolicy.UtcSetLastModified (DateTime utcDate)
by bhartsock on Feb.21, 2009, under Uncategorized
I spent most of yesterday configuring a server, then delving into the aforementioned error with a few other devs. Here is basically what we did to figure it out, and what the cause was.
The error
The day started by setting up a new server, and getting our ASP.NET application up and running. At first, the error wasn’t apparent. It was when we started seeing javascript errors on different pages. It looked as though one javascript includes was causing the error, /WebResource.axd?d=KadOK03KouGAGUGwjTWw4w2&t=633707613869062500.
When pulling up the included javascript file directly in the browser, the full error was seen.
Type : System.ArgumentOutOfRangeException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Specified argument was out of the range of valid values.
Parameter name: utcDate
Source : System.Web
Help link :
ActualValue :
ParamName : utcDate
Data : System.Collections.ListDictionaryInternal
TargetSite : Void UtcSetLastModified(System.DateTime)
Stack Trace : at System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)The problem
Google quickly helped me figured out what was causing it, some assemblies were dated in the future.
I was a little confused as to why though. I looked at the timestamp portion of the request, to see what its value was, /WebResource.axd?d=KadOK03KouGAGUGwjTWw4w2&t=633707613869062500.
PS C:\> new-object DateTime 633707613869062500 Friday, February 20, 2009 9:16:26 PM PS C:\> [DateTime]::Now Friday, February 20, 2009 1:21:22 PM
So the assembly trying to be loaded is ~8 hours in the future, not good.
Who is causing the problem?
Now I know what the problem is, but looking through all the DLL’s for timestamp problems could take forever. Powershell to the rescue.
gci -recurse | where { $_.LastWriteTime -gt [DateTime]::Now }
I ran this on the application directory, then C:\Windows\Microsoft.NET, then C:\Windows\assemblies.
Bam. The problem was in C:\Windows\Microsoft.NET and C:\Windows\assemblies.
(Side note: Smarty pants Lamar showed this could be done with just Windows search and ordering by the date column.)
My first idea
Can I change the LastWriteTime of a file?
PS C:\> gi c:\ | get-member LastWriteTime TypeName: System.IO.DirectoryInfo Name MemberType Definition ---- ---------- ---------- LastWriteTime Property System.DateTime LastWriteTime {get;set;}
Yes, there is a setter!
gci -recurse | where { $_.LastWriteTime -gt [DateTime]::Now } | %{ $_.LastWriteTime = [DateTime]::Now }
Well, that worked for C:\Windows\Microsoft.NET, but not C:\Windows\assemblies since all the DLLs in there are in use.
The final solution
Reinstall .NET framework, entirely. I know, you were expecting something amazing, and I failed you. Well, sorry. I was annoyed too, but it was the easiest way I could think accomplish the task. What is important is how I was able to use Powershell to test out different scenarios and possible solutions. If I would have had to write a command line program in Visual Studio to figure out what different timestamp values actually were, I wouldn’t have done it.
The other question you might have is why were times so off? Well, the server was a fresh install and the time wasn’t set properly for some reason. .NET was installed before checking the time that was set. This would have been fine, but the server was added to the AD domain, which quickly changed the time to the correct time.
Powershell? Yes
by bhartsock on Nov.28, 2008, under Uncategorized
I have read over Scott Hanselman’s Tool List at least a dozen times. The first time I read it, I saw that Powershell was on his top 10. I knew a little about Powershell from Exchange 2007 but hadn’t taken any time to look at it.
About a month ago, I had to write some server maintenance scripts. Things like deleting files older than X days, SQL Server maintenance, etc. These tasks were perfect for scripting, so I picked up a Powershell book and went to town. It took a while to pick it up, but my overall impression of Powershell is wow. Powershell fills that void in the soul of Windows that developers hate. Now scripting in Windows doesn’t have to involve Cygwin and Perl, even though Perl will always stay close to my heart.
Powershell combines the ease of scripting with the power of .NET. It is a loosely typed language that can work with strongly typed objects from .NET. For me, it boils down to scripting objects instead of text. In Bash, grep and awk had to be used when parsing the output of any program. In Powershell, the output of a program is usually an object, which is much easier to work with.
The following line sums up why I love Powershell. It deletes files older than 14 days in a directory. While this is a trivial example, it is so simple, and so elegant.
gci c:\directory | where { $_.LastWriteTime.AddDays(14) -lt [DateTime]::Now } | ri
Amazon Unbox + XBox = Joy; Goodbye Ubuntu
by bhartsock on Oct.26, 2008, under Uncategorized
Yesterday I found this gem of an article on Amazon’s website. I wish I had known about it sooner.
I got home, and immediately tried it out. After about 1 minute, I was watching an on-demand video on my TV, through my XBox. Before, I thought I had to go through a VGA cable directly from my laptop, which is a pain. This is much better.
The quality isn’t HD; it looks to be about DVD quality. Even still, I think it is enough for me to cancel my satellite subscription and be completely on-demand. I only watch 2 TV shows, and the rest just waste my time. If only Discovery and History channels streamed over the internet, I wouldn’t miss satellite at all.
Also, I think this is the catalyst to get me to ditch my Ubuntu desktop for a Windows machine. Being able to easily have on-demand video is a perk like none other. At long last, I have given up what I so fell in love with a few years ago. I am sure this isn’t are last meeting, goodbye Ubuntu.