Debugging Silverlight Tip

by Donn Felker 21. November 2008 03:09

If you're doing any kind of Silverlight work you're bound to get "Error on page" in Internet Explorer. Here's what I'm talking about.

You fire up your app in the browser window and BLAM. Screen is empty and you get the "Error in page" error. Double click the error and you get an Internet Explorer JS Error Window. Here it is in all its glory:

 image

 

How Do I Catch The Exception in Code?

The exception IS happening in code you're just not catching un-handled exceptions.

To turn them on, go to Debug --> Exceptions:

image

You'll get the window below. Check the "Common Language Runtime Exceptions" checkbox and click OK.

image

 

You will not get exceptions bubbled up to the Dev Environment. Here's what it looks like in action  (with the same error as the "blank screen" above).

image

 

Click "Break" and break into the area where the code barfed on you, and then clean up the mess you've created (on accident of course - who creates un-handled exceptions for fun anyway). :)

 

Enjoy.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Silverlight | Visual Studio

XamlParserException - AG_E_PARSER_BAD_TYPE

by Donn Felker 14. November 2008 04:11

Ohhhhh the dreaded XamlParserException. The exception message is not to helpful at all.

In my instance I was working with Silverlight. Namely working with the Prism  V2 Drop #5 from the Composite WPF team. Get the latest and read up the project here. I was loading the TreeView control into my view (Xaml) and when the app fired up the project would bomb with this exception and the message was VERY informative *sarcasm*.

AG_E_PARSER_BAD_TYPE

Hmm... Ok. Sure. Sounds good.

I have my projects laid out like so.

image

 

The Prism Shell (Top) loads different modules at runtime. Module A has a view (View 1) which has a tree view. Therefore, Module A (which is a Silverlight App itself) references the Microsoft.Windows.Controls library which contains the new controls for Silverlight (download them here). When this was getting compiled and referenced at runtime, the Microsoft.Windows.Controls dll was not in the Shell project, therefore it would blow up when it tried to parse the Xaml. Giving me the lovelly and dreaded XamlParserException.

The Fix

Simple. Add a reference to the Microsoft.Windows.Controls dll in the main Prism App. Then.... BLAMMO... the control toolkit works as expected. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Silverlight

Silverlight Cross Domain Issue

by Donn Felker 12. November 2008 07:31

I'm doing some Silverlight Development and I ran into a wacky issue (or so it seemed at the time).

The Silverlight app would connect to a Java Web Service and get some data (XML). The end result is that this Silverlight app will talk to Java Web Services and the xap file sit on a java web server and be downloaded to the client. During development its done on Windows Machines/VM's (of course). However, when we connected to the service, it would bomb with a Security Exception as follows:

 

A first chance exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.dll

Additional information: An error occurred while trying to make a request to URI 'http://example.org:7001/beans/TestWebServiceBean'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. Please see the inner exception for more details.

At first glance this looks like an issue with the services clientaccesspolicy.xml file. But looking at the requests through fiddler or Web Dev Helper we can see that an HTTP success (200) was occurring for the requests of those files. They were coming back as expected.

 

CAS: True Smoke and Mirrors

The problem was due to the fact that we running Silverlight under the Test html page from the file system. So it would look something like this:

C:\SVNHome\path\to\project\Bin\Debug\TestPage.html

The Silverlight app would call a web service on the network or Internet. Them, BOOM all hell would break loose. Security exceptions flying around like snowflakes in Minnesnowta.

It looks like this was an issue with Code Access Security. Now I'm not exactly 100% sure where in the CAS stack this error occurred, but I do know that the local file was in a different zone than the Internet zone and when executing code in different zones you run into tons of CAS issues (SecurityExceptions). <Sarcasm>Read more about the super exciting world of CAS here </Sarcasm>. 


So I created a ASP.NET Web App and linked the Silverlight app with the Web App. I fired up the test page which now looks like this:

http://localhost:3399/SilverlightApplicationWevSvcTestTestPage.aspx

BOOM! The app worked just like it should have. Looks like a definite culprit of the deadly CAS. :)

:)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Silverlight | WCF

By Far, The Coolest Flash App I've EVER Played With

by Donn Felker 30. April 2008 23:13

I've played with a lot of Flash applications, hell, I've written a TON of them. I was one of the very few developers developing/integrating PHP/MySQL/Flash 5/MX/ActionScript programming that I know of at the time. Here's a few links to some of them I built that are still online.

Unfortunately the Internet archive doesn't keep track of flash movies that well otherwise I'd link the SUPER COOL ones (tons of animation based upon user input and data from the persistence store) I did that had TONS of integration. I had a ton of other ones that I've done but either the band or label went under so they're not online and I don't have a portfolio site for them (although I should for historical purposes). Between my stints at Lava Records, Atlantic Records, Dreamworks Records, Nitro Records and the now defunct Grave 9 Records I wrote a lot of PHP/MySQL and Actionscript. Thank god those days are over. Oh .NET how I love thee... anyway... enough geek talk.

Why The Best Ever?

One of my favorite hip-hop artists, Atmosphere, released a new album called "When Life Gives You Lemons" (You Paint That Sh!t Gold). Seriously, its a great album, but this isn't a music review site - its a technology blog so lets back to topic Felker ...

With the release of this album they released a web app that allows users to "Tag The World" (www.paintitgold.com) which in effect lets the user take a screen capture (through the use of a Flash App) by typing in a URL and then you can use a set of tools to tag up the site of your choice.

You can use spray paint, stencils, different colors, sizes, markers, etc, its cool. I literally lost about 2 hours on this site. I got sucked in this evening. That NEVER happens, so when it does I'm completely amazed at how the site did it. After being on the net for 10+ years I thought I'd seen it all, NOPE. This is cool. I've seen some "Paint" sites before, but this one got me sucked in.  The other sites that implemented the "paint" feature were very MSPaint. Lets face it, MSPaint, well... sucks. Its great to grab screen shots, but then again, why aren't you using Paint.NET?

Anyway, that aside here's what I did to my site. Honestly, I must have created over 50 of these before I just said screw it and decided to save it for the heck of it.

(click the image to see a larger version on the actual site)

The real awesome-ness is that the spray paint has pressure, and you can size the stencils, rotate them, and just go crazy in general. Afterwards,  you can submit your "masterpiece" (if you want to call it that - mine definitely is ... look at my new digs on my picture above - *haha*) to a gallery on the site. Afterwards it gives you code to post your masterpiece on your blog (which is how I got it to my site).

Conclusion

Take a look at how simple it is to use this site.

I mean it, literally look at how easy it is to use. You don’t have to be a computer genius to get it to work. It just works. This site has a GREAT UX and its fun as hell. There is music playing in the background. You get to tag up a site, hell, just have fun, and you can save your drawing in the end. Every single Web 2.0 designer that wants to make a fun compelling app can learn something from this site. The saying goes "Don't Make Me Think". Not only did this site NOT make me think, it led my hand to allow me to escape into their site (and literally escape reality for a couple of hours).

The only thing I wish they had was a "undo" feature that worked as I expected. From what I could find it you could only "clear the canvas" ... but... then again... this is a hip hop site and the hip hop culture embraces graffiti, and in a true blank canvas sort of way this site embraces the graffiti element beautifully. In the real world you can't just "undo" a line of paint on a wall (or train for that matter). :) You have to keep on going whether you like the piece or not. Its art. :)

Final Thoughts

Kudos to the developers of this site, great job guys.

Heuer lets create a version in Silverlight that blows this one out of the water. :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Design | Silverlight | Web 2.0

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Donn Felker

Senior Consultant
MCTS
ScrumMaster
Agile Practitioner

About Me | Books I Recommend

Gotta Pay The Bills


Tag cloud

    Popular Posts

    RecentComments

    Comment RSS

    Calendar

    <<  December 2008  >>
    MoTuWeThFrSaSu
    24252627282930
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    View posts in large calendar