Silverlight

Cross-domain policy issue in Silverlight application

Error:
“An error occurred while trying to make a request to URI. 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.”

1. Create an xml file using notepad and save as clientaccesspolicy.xml with the following content.

<?xml version=”1.0″ encoding=”utf-8″?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers=”SOAPAction”>
        <domain uri=”*”/>
      </allow-from>
      <grant-to>
        <resource path=”/” include-subpaths=”true”/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
2. Create an xml file using notepad and save as crossdomain.xml with the following content.
<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
  <allow-http-request-headers-from domain=”*” headers=”SOAPAction,Content-Type”/>
</cross-domain-policy>
3. Copy these 2 files into web site root folder for example, c:\inetpub\wwwroot. for your IIS (local system) or in root folder of website(c:\inetpub\wwwroot\controlsdemowcf)  on server (2008, 2003).

How add two xaml to aspx page

You can have one Silverlight application project (one xap file).  Assume it contains two UserControls Page1.xaml and Page2.xaml, and you want Page1 to be shown in Silverlight Control1, and Page2 to be shown in Silverlight Control2 in the same aspx page.

You can use initParams in the Silverlight control tag to indicate which UserControl you want to use as the application start up page:

Code in App.xaml Application_Startup:

private void Application_Startup(object sender, StartupEventArgs e)
{

if(e.InitParams.ContainsKey[“Page”])

{

string page = e.InitParams[“Page”];

if(page == “Page1”)

this.RootVisual = new Page1();

if(page == “Page2”)

this.RootVisual = new Page2();

}

}