Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

WCF Service problem RSS

15 replies

Last post Oct 11, 2008 02:52 PM by StefanG

(0)
  • StefanG

    StefanG

    Member

    12 Points

    30 Posts

    WCF Service problem

    Oct 09, 2008 10:00 PM | LINK

    Hi All, 

    I mentioned this in another thread but it was a bit off-topic so I decided to start a dedicated thread. I have deployed a WCF service and my Silverlight application on a server (not where I develop). When opening the application from the server (not even cross-domain) I get the following error:

     Microsoft JScript runtime error: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
       at MySilverlightProject.MyService.MyServiceMethodCompletedEventArgs.get_Result()
       at MySilverlightProject.App.client_MyServiceMethodCompleted(Object sender, MyServiceMethodCompletedEventArgs e)
       at MySilverlightProject.MyService.MyServiceClient.MyServiceMethodCompleted(Object state)

     Just in case I do have the crossdomain.xml and clientaccesspolicy.xml in the root folder of the Silverlight application. Furthermore I tried to reference the WCF service from a simple Windows Forms app and it worked smoothly. Also within my Silverlight application I use literally the same (copy & pasted) routine as in the windows forms app, this includes setting up a BasicHttpBinding and Endpoint objects.

    Any ideas on how I can debug this and get more information about what actually went wrong and what the problem is?

    Thanks,

    Stefan

  • pbromberg

    pbromberg

    Contributor

    3138 Points

    531 Posts

    Re: WCF Service problem

    Oct 10, 2008 12:40 AM | LINK

    You really need to post a more complete code sample for this, in order to expect more meaningful help posts. The key thing I see here is "Microsoft JScript runtime error". Can you post some sample code please?

    [C# MVP]
    Eggheadcafe.com
  • amit_pal1979

    amit_pal1979

    Participant

    1150 Points

    202 Posts

    Re: WCF Service problem

    Oct 10, 2008 07:24 AM | LINK

    "I do have the crossdomain.xml and clientaccesspolicy.xml in the root folder of the Silverlight application"

    You do not need to place these files in Silverlight application rather on the root folder of your webserver. For e.g, if you are using IIS, then it will be C:\inetpub\wwwroot.

    You can place any of these files and that should work however for more flexibility, it is advisable to put only clientaccesspolicy.xml. This is the file which will be checked first and if this is not found then it checks for crossdomain.xml. So, just copying clientaccesspolicy.xml will do the job.

     

    Please mark the post as 'Answered' if this Answers your question

     

  • HarshBardhan

    HarshBardhan

    Star

    10118 Points

    1749 Posts

    Re: WCF Service problem

    Oct 10, 2008 07:26 AM | LINK

    Hi,

    I don't think it is policy file which is causing the issue(As it can not be javascript).I think it is some thing else.

    Please proveide some more details for this.

    Mark as answer if this post answered your question.

    Harsh Bardhan
  • StefanG

    StefanG

    Member

    12 Points

    30 Posts

    Re: WCF Service problem

    Oct 10, 2008 07:44 AM | LINK

     Thanks for the prompt replies. 

    Bellow is the code I use to call the service from within Silverlight. The reason I didn't post code is because when I was developing both the WCF service and the Silverlight app I had them in one solution (so no cross-domain calls) and they were working fine.The problems started appearing when I deployed them to the server. I was hoping this would be a common error :)

    Anyway.. this is how I call the service. The code resides in private void Application_Startup(object sender, StartupEventArgs e) in App.xaml.cs because I need to fetch the data and use it to initialize my canvas:

                 BasicHttpBinding bind = new BasicHttpBinding();
                EndpointAddress endpoint = new EndpointAddress("http://192.168.1.69:5554/CRMProxyService.svc");

                CrmProxyService.CRMProxyServiceClient client = new CRMProxyServiceClient(bind, endpoint);
                client.GetRelationSubjectCompleted += new EventHandler<GetRelationSubjectCompletedEventArgs>(client_GetRelationSubjectCompleted);
                client.GetRelationSubjectAsync("{A0E89268-37E6-DC11-A6B2-0003FF38484A}");

    The callback method simply initializes the page:

     void client_GetRelationSubjectCompleted(object sender, GerRelationSubjectCompletedEventArgs e) { RootVisual = new Page(e.Result); }

    As for the deployment, the server is a VPC. I have deployed the WCF Service and the Silverlight app as two separate websites in IIS.

     As for the cross domain xml files, I did just now put them in the wwwroot as well as in the actual website root of the Silverlight website (I thought that's where they should be) but I still get the same thing. In addition when I open the Silverlight website from within the server (no cross-domain?) I still get the same exact error.

    Thanks,

    Stefan

  • Brauliod

    Brauliod

    Contributor

    2448 Points

    744 Posts

    Re: WCF Service problem

    Oct 10, 2008 10:12 AM | LINK

  • StefanG

    StefanG

    Member

    12 Points

    30 Posts

    Re: WCF Service problem

    Oct 10, 2008 10:27 AM | LINK

    Thanks for the reply Braulio.

     The only difference that I could see between my setup and the post is that the clientpolicy.xml was different.

    Mine was:

    <?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
      <allow-access-from domain="*" />
    </cross-domain-policy>

     and the post suggests I use

    <?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="*"/>
    </cross-domain-policy>

     I changed it the but error stays exactly the same. Also, for reference, this is my clientaccesspolicy.xml

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

  • Brauliod

    Brauliod

    Contributor

    2448 Points

    744 Posts

    Re: Re: WCF Service problem

    Oct 10, 2008 11:58 AM | LINK

    Just a silly question, does your web service call return a lot of data? It should fail as well on your dev environment (if you use the same data), I face that some weeks ago, and It take me some time to realize that I had to setup a bigger buffer.

  • party42

    party42

    Participant

    1150 Points

    351 Posts

    Re: Re: WCF Service problem

    Oct 10, 2008 12:03 PM | LINK

    it was something like this. dont have visual studio here so not sure about syntax but  something like below should work.

    BasicHttpBinding binding = new BasicHttpBinding();
    binding.MaxReceivedMessageSize = 2147483647; // int's max size
    binding.MaxBufferSize = 2147483647; // int's max size
    EndpointAddress endpoint = new EndpointAddress("http://192.168.1.69:5554/CRMProxyService.svc")
    
     
    Regards,
    Nathan Brouwer

    http://www.nathanbrouwer.nl
  • edward_494

    edward_494

    Member

    149 Points

    86 Posts

    Re: WCF Service problem

    Oct 10, 2008 01:42 PM | LINK

    about the clientaccesspolicy.xml fle. where does it need to go when running in development? i currently have it in the folder/project root level of my service.