Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 173265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:18:47+00:00 2026-05-11T13:18:47+00:00

I have Vista with IIS7 . I want to create a simple Silverlight application

  • 0

I have Vista with IIS7.

I want to create a simple Silverlight application that reads an xml file from localhost.

I created this file (which I had to copy and click ‘allow’ as administrator):

C:\inetpub\wwwroot\data\customers.xml

and can see it when I go here in a browser:

http://localhost/data/customers.xml

But when I run the following code, I get a target invocation exception:

using System; using System.Net; using System.Windows.Controls; using System.IO;  namespace TestXmlRead234 {     public partial class MainPage : UserControl     {         public MainPage()         {             InitializeComponent();              WebClient client = new WebClient();             client.OpenReadAsync(new Uri('http://localhost/data/customers.xml', UriKind.Absolute));             client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);         }          void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)         {             StreamReader myReader = new StreamReader(e.Result);             Output.Text = myReader.ReadLine();             myReader.Close();         }     } } 

So I created C:\inetpub\wwwroot\crossdomainpolicy.xml:

<?xml version='1.0' encoding='utf-8'?> <access-policy>     <cross-domain-access>         <policy >             <allow-from http-request-headers='Content-Type'>                 <domain uri='*'/>             </allow-from>             <grant-to>                 <resource path='/' include-subpaths='true'/>             </grant-to>         </policy>     </cross-domain-access> </access-policy> 

But I still get the target invocation exception error.

Here is the full inner exception:

{System.Security.SecurityException —> System.Security.SecurityException: Sicherheitsfehler bei System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) bei System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.b__4(Object sendState) bei System.Net.Browser.AsyncHelper.<>c__DisplayClass2.b__0(Object sendState) — Ende der internen Ausnahmestapelüberwachung — bei System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) bei System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) bei System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) bei System.Net.WebClient.OpenReadAsyncCallback(IAsyncResult result)}

update 1: In windows explorer, I then right clicked C:\inetpub\wwwroot\data and made IIS_USERS a co-owner of that directory. But still get the same error. 🙁

update 2: also made ‘everyone’ co-owner of C:\inetpub\wwwroot\data, same error. 🙁

update 3: opened command window as administrator and executed this command: netsh http add urlacl url=http://+:80/ user=MYDOMAIN\MyUserName

What else do I have to be able to read a text file from localhost from a Silverlight application?

PRAGMATIC ANSWER:

For testing locally just publish to the temporary localhost webserver port for which you don’t even need a cross-domain file, then make necessary changes when you publish live:

using System; using System.Linq; using System.Net; using System.Windows.Controls; using System.IO; using System.Xml.Linq;  namespace TestWeb124 {     public partial class MainPage : UserControl     {         public MainPage()         {             InitializeComponent();              WebClient wc = new WebClient();             wc.OpenReadAsync(new Uri('http://localhost:49512/customers.xml', UriKind.Absolute));             wc.OpenReadCompleted += wc_OpenReadCompleted;         }          private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)         {             if (e.Error != null)             {                 Output.Text = e.Error.Message;                 return;             }             using (Stream s = e.Result)             {                 XDocument doc = XDocument.Load(s);                 Output.Text = doc.ToString(SaveOptions.OmitDuplicateNamespaces);                 var customers = from c in doc.Descendants('customer')                                 select new                                 {                                     FirstName = c.Element('firstName').Value                                 };                  foreach (var customer in customers)                 {                     Output.Text += customer.FirstName;                 }              }         }                } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:18:48+00:00Added an answer on May 11, 2026 at 1:18 pm

    From what I’ve seen, the usual behaviour is to create a webservice that can get around Silverlight’s cross domain issues entirely, then have Silverlight code communicate through that web service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET application developed on my Vista box (IIS7). It works fine
I have a simple PowerShell script that uses WMI to create a web site
I have built a Vista Gadget. It grabs a local XML file called settings.xml.
I have a VB.Net program running on vista that says a file is in
I have Vista x64 IIS7 running on my dev. machine. I used to use
I have a web site running via IIS7 on Vista. The site is running
I have an ASP.Net 2.0 application that uses integrated Windows Authentication to authenticate/authorize users.
I have a Windows Vista PC with IIS7, I have managed to manually install
Can I have a Windows Vista/7 gadget where the app is loaded from a
I have a WinForm .NET 2.0 framework app that works fine in Vista, Win

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.