Retrieve baseUri w/o resorting to Application.Current
Posted
by beaudetious
on Stack Overflow
See other posts from Stack Overflow
or by beaudetious
Published on 2010-04-15T20:35:02Z
Indexed on
2010/04/15
20:43 UTC
Read the original article
Hit count: 263
Silverlight
My custom controls are not loading in VS.NET's designer because of a null reference exception. It's got everything to do with the way I am retrieving the baseUri of the application when it runs in the browser:
_uriPrefix = Application.Current.Host.Source.AbsoluteUri.Substring(0,
Application.Current.Host.Source.AbsoluteUri.IndexOf("/ClientBin")).Trim();
According to the exception details and the help file I'm directed to (here) I'm not correctly designing my app for a runtime that's not the browser (i.e. the new WPF editor in VS.NET or Expression Blend).
So, the question is how do retrieve the baseUri (the http://localhost:#### part of my application) if I can't use Application.Host which apparently is null during design time? is there a safe way to do this so I can load my custom controls in a designer?
© Stack Overflow or respective owner