0
votes

before i start i should say that i use silverlight3 and .Net 3.5. i have a wcf class library with some methods in it and i've added it to a silverlight class library(to add the wcf class library,first i added the entire my wcf class library project to the silverlight class library solution and then i add a service reference of wcf class library to my silverlight class library),imagine that the output of the silverlight class library is a usercontrol so i added the class library to a silverlight Application(my main project) as a service refrence to use the usercontrol But when the application wants to instantiate the usercontrol is throw an exception

An error occurred while trying to make a request to URI 'http://localhost:8732/Design_Time_Addresses/GalleryShopWCFService/GalleryShopService/'. 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.

i know that i should have a cleintaccesspolicy.xml file but i don't know where.

2

2 Answers

0
votes

You can solve this issue in two ways.

First: your shop service can implement method providing access policy for Silverlight applications:

public interface IGalleryShopService
{
    [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]
    Stream GetSilverlightClientAccessPolicy();

    /* other contracts declarations */
}

In actual implementation, you need to return actual XML as stream. XMLs examples for Silverlight can be found at MSDN.

Second: simply put clientaccesspolicy.xml in root directory of your service implementation, as explained in this blog post.

0
votes

Simply put clientaccesspolicy.xml in the root directory i.e.

c:\inetpub\wwwroot\clientaccesspolicy.xml 

then it will work.

Because your website search clientaccesspolicy.xml in the http://localhost/clientaccesspolicy.xml or else you can change the path of your xml file. Put it to root using virtual directory.