Beginning WPF

I’ve decided to start learning WPF. No real reason, I just felt like switching context for a while. I went out and bought Adam Nathan’s book Windows Presentation Foundation Unleashed, on account of all those nice reviews of it that I’ve been reading. But this isn’t about Nathan’s book – I’ve barely even started on Chapter 3 just yet.

I was going along merrily, writing up some code XAML code from the book and just running it in the browser. The first examples, about creating a button, were working just fine that way. Until I tried a bigger example, creating a simple window:
Example WPF window

When I ran that, it gave me a huge stack trace, a dump, and I’m pretty sure I saw a MD5 hash of Bill Gates’ full name in there somewhere. It’s two A4 pages of SecurityException goodness. Based on some vague memories of the cause last time I had a SecurityException, trying to run .NET code off a network drive, and from what was different in the code this time around, I figured that perhaps you couldn’t have a <Window> in a browser. In that 175-line error message, the closest thing to something useful was this:
at System.Windows.Window..ctor()

And then only because I happen to know that in .NET, a .ctor() is a constructor, so I’m figuring here that there’s an exception in the constructor for a System.Windows.Window. Really. Those other 174 lines might be useful from time to time, but would it really be unthinkable to create something that says, “The current environment lacks permissions to create a System.Windows.Window” up top. Or something like that?’

I wonder if doing it in Visual Studio .NET (2008) gives better results. One would certainly hope so.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: