Click here to Skip to main content
13,200,633 members (53,744 online)
Rate this:
Please Sign up or sign in to vote.
See more: , +
Hi friends,

I'm facing cross domain issue while running the application, error is

System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'hhtp://localhost/Silverlight/Services/abcservice.svc'. This could be due to attempting to access a service in a cross-domain way without a cross-domain policy in the place, or a policy that is unsuitable for soap services.This error may also be created by using internal types in the web service proxy without using the InternalVisibleAttribute attribute. Please see the inner exception. --> blah blah

I searched and found one site [^]that gives solution to the cross domain error sighs!!!!

I done exactly what he says but there is no solution.

I copied a clientaccesspolicy.xml and crossdomain.xml file and placed it in root folder of my project.

But the service(.svc) and its code file (.cs) is placed in my project within a folder named service.

According to the site it says, placing the two xml files in the root folder that has service in it will resolve the issue.
But in my case it does'nt.

what should i do?

Please help me asap!!!!
Any ideas will be greatly appreciated!!!
Posted 17-Sep-12 3:26am
Updated 17-Sep-12 19:30pm
TRK3 17-Sep-12 18:48pm
You need to give us more information if you expect to get some help.

What is the exact error message/code? When/where does it occur?

You say you "copied a clientaccesspolicy.xml and crossdomain.xml file and placed it in root folder of my project"

(a) those files are supposed to go on the root of the server [which probably isn't the same as the "root folder of my project"]

(b) there is no way to tell if what you have in those files is actually what you need to have in those files.
rk_prabakar 18-Sep-12 1:30am
I edited my question.....
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want to call a web-service then the root of the website must have a crossdomain.xml that contains:

<!DOCTYPE cross-domain-policy SYSTEM "">
<allow-http-request-headers-from domain="*" headers="*"/>

Look at:[^]
rk_prabakar 18-Sep-12 1:45am
Thats what i mentioned already i did copying the crossdomain.xml and clientaccesspolicy.xml in remote folder but nothing works out
Kuthuparakkal 18-Sep-12 1:50am
Not just copying will do :
The article says; "To allow access to an HTTPS service from any Silverlight control hosted over HTTP application, you need to put the "<domain uri=”https://*”"></domain> element inside your <allow-from> element.
rk_prabakar 18-Sep-12 2:00am
I did that too.... i added for http and https as well.
Kuthuparakkal 18-Sep-12 2:16am
updated solution, try now
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Sometimes something turns in to my way.
I did everything that i can, but stuck with that error.
I searched in google for this error, placed clientaccesspolicy.xml in service folder, placed crossdomain.xml in the same.But nothing works for me.

Then only struck, i try to add port number into my service address path in the ServiceReferences.ClientConfig file.
Earlier it was like
<endpoint address="http://localhost/Services/ManualFileUpload.svc">
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ManualFileUpload"
contract="UploadFileService.ManualFileUpload" name="BasicHttpBinding_ManualFileUpload" /></endpoint>

I added port number(4009) to the address like this
<endpoint address="http://localhost:4009/Services/ManualFileUpload.svc">
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ManualFileUpload"
contract="UploadFileService.ManualFileUpload" name="BasicHttpBinding_ManualFileUpload" /></endpoint>

Now it works fine and cool in the application.
And now Crossdomain policy error got resolved.

Thanks friends.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I have also faced the same issue and after a week of my trails got to know that having ClientAcessPolicy.xml and CrossDomainPolicy.xml in the root directory will not serve u r request, the ClientAcessPolicy.xml and CrossDomianPolicy.xml must be sent through the service only.

Follow the below steps to solve this issue

1. Add a new NameSpace in Iservice1.cs as shown below

[ServiceContract(Namespace = "http://ServiceWCF")]
        public interface IPolicyRetriever
           [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]
           Stream GetSilverlightPolicy();
           [OperationContract, WebGet(UriTemplate = "/crossdomain.xml")]
           Stream GetFlashPolicy();

2. Now edit the Service1.svc file with edits,

public class PolicyClass : IPolicyRetriever
        Stream StringToStream(string result)
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";
            return new MemoryStream(Encoding.UTF8.GetBytes(result));
        public Stream GetSilverlightPolicy()
            string result = @"<!--?xml version=""1.0"" encoding=""utf-8""?-->
                                        <allow-from http-request-headers="" *""="">
                                            <domain uri="" *""="">
                                            <resource path="" ""="" include-subpaths="" true""="">
            return StringToStream(result);
        public Stream GetFlashPolicy()
            string result = @"<!--?xml version=""1.0""?-->
                                <allow-access-from domain="" *""="">
            return StringToStream(result);

4. Now Add both the file in the Project Location
5. Better to avoid some of the problems we can add both the file in the Root Folder also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 25 Oct 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100