Skip to main content

Microsoft Silverlight

Answered Question Error Creating XAML Object using XamlReader.LoadRSS Feed

(1)

ahhmedsherif
ahhmedsh...

Member

Member

66 points

80 Posts

Error Creating XAML Object using XamlReader.Load

 I am getting a System.UnauthorizedAccessException when creating a  XAML Object using the following string ..

Any Ideas ? - Yes the server root has the required clientpolicy files

Sample code

string xamlObject = "<Image Source=\"http://shahmed-l2:8080/Balrog/FireImagingProcessor?request=getImage&amp;fireName=Piute Fire\" Tag=\"-118 35 -118 36\"/>"

XamlReader.Load(xamlObject)

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Answered Question

Re: Error Creating XAML Object using XamlReader.Load

You need to include the namespace info in your xaml if you use XamlReader to load it:

string xamlObject  = "<Image xmlns='http://schemas.microsoft.com/client/2007'
              xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
  Source=\"http://shahmed-l2:8080/Balrog/FireImagingProcessor?request=getImage&amp;fireName=Piute Fire\" Tag=\"-118 35 -118 36\"/>"

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

Bill Reiss
Bill Reiss

Contributor

Contributor

4840 points

919 Posts

Silverlight MVP

Re: Error Creating XAML Object using XamlReader.Load

With any of these things that might possibly have something to do with clientaccesspolicy.xml or crossdomain.xml I recommend using Fiddler http://www.fiddlertool.com/fiddler/ to make sure that the policy file is actually being retrieved properly and you're not getting a 404.


Bill Reiss, Coauthor of Hello! Silverlight 3
My blog (rss feed)

ahhmedsherif
ahhmedsh...

Member

Member

66 points

80 Posts

Re: Error Creating XAML Object using XamlReader.Load

Thats exactly I do, use Fiddler to monitor traffic.. as I mentioned in the original post, the clienaccesspolicy files are fine and are working for many other services on the same web server.

I am going to try the parsing with the Namespaces included.Thanks for your suggestions.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Error Creating XAML Object using XamlReader.Load

Bill Reiss:

With any of these things that might possibly have something to do with clientaccesspolicy.xml or crossdomain.xml I recommend using Fiddler http://www.fiddlertool.com/fiddler/ to make sure that the policy file is actually being retrieved properly and you're not getting a 404.


I thought he is loading a Xaml string into XamlReader, not from a file. Why it has anything to do with clientaccesspolicy.xml file?

[Edit]

Oh, I got it. You mean the image loading might cause the problem.

 

ahhmedsherif,

I think you'd better change your image source URL. The URL you are using contains port number which is only valid when you develop using the Dev Server. And that port number is dynamic (could change if you shut down the dev server and start it again) unless you fixed it in your Web project property page. If that port number changed you would have problem. Even it works all the time while developing, once you deploy your app, you would have problem again. Because you are using a hardcoded URL which no longer avaiable after you deploy your app.

string xamlObject = "<Image Source=\"http://shahmed-l2:8080/Balrog/FireImagingProcessor?request=getImage&amp;fireName=Piute Fire\" Tag=\"-118 35 -118 36\"/>"

You can specify the relative url to avoid this problem. Try something like this if your FireImagingProcessor service is under Balrog folder under your Web project:

Source=\"..//Balrog/FireImagingProcessor?request=getImage&amp;fireName=Piute Fire\"


 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities