Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Error Creating XAML Object using XamlReader.Load
4 replies. Latest Post by sladapter on July 18, 2008.
(1)
ahhmedsh...
Member
66 points
80 Posts
07-17-2008 10:43 PM |
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&fireName=Piute Fire\" Tag=\"-118 35 -118 36\"/>"
XamlReader.Load(xamlObject)
sladapter
All-Star
17441 points
3,172 Posts
07-17-2008 10:59 PM |
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&fireName=Piute Fire\" Tag=\"-118 35 -118 36\"/>"
Bill Reiss
Contributor
4840 points
919 Posts
07-17-2008 11:37 PM |
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.
07-18-2008 12:12 AM |
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.
07-18-2008 10:12 AM |
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.
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&fireName=Piute Fire\"