Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -05001735184http://forums.silverlight.net//p/11057/35184.aspx/1?calling+wcf+service+problemscalling wcf service problems <p>I created a simple wcf service added servicereference to silverlight project and when I access the service I get the following error. if I create a website and add servicereference to the same service it works just fine, so there is no problem with the service</p> <p>any Ideas?</p> <p>An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.dll but was not handled in user code</p> <p>Additional information: [CrossDomainError]<br> Arguments:<br> Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See <a href="http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.30226.2&amp;File=System.ServiceModel.dll&amp;Key=CrossDomainError"> http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.30226.2&amp;File=System.ServiceModel.dll&amp;Key=CrossDomainError</a><br> </p> 2008-03-09T11:56:16-04:0035488http://forums.silverlight.net//p/11057/35488.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>any help?</p> 2008-03-10T13:22:09-04:0035539http://forums.silverlight.net//p/11057/35539.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>By default WCF services are set to use the wsHttpBinding.&nbsp; You will need to change that to BasicHttpBinding in your web.config.&nbsp; Hopefully that is the problem.</p> 2008-03-10T15:54:14-04:0035600http://forums.silverlight.net//p/11057/35600.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>it is set to BasicHttpBinding. I am afraid that is not the problem</p> 2008-03-10T18:41:23-04:0035664http://forums.silverlight.net//p/11057/35664.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>Ok, shot in the dark here but where is the WCF service being hosted?&nbsp; Is it on a different domain/port than where the SL plugin is being loaded from?&nbsp; Just trying to see if the CrossDomain error reported is relevant.&nbsp; If indeed they are on two different domains (and this includes different development ports) then you will need to place a cross domain policy file with the WCF service.</p> 2008-03-10T22:07:22-04:0035694http://forums.silverlight.net//p/11057/35694.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>Ya, and related to this last post, here is an article that goes over URL Access Policy and ways to get cross domain access: <a href="http://msdn2.microsoft.com/en-us/library/cc189008(vs.95).aspx">http://msdn2.microsoft.com/en-us/library/cc189008(vs.95).aspx</a></p> 2008-03-11T00:24:36-04:0035737http://forums.silverlight.net//p/11057/35737.aspx/1?Re+calling+wcf+service+problemsRe: calling wcf service problems <p>WCF service is in the same solution hosted on the same box(localhost), I created the policy file dropped in C:\Inetpub\wwwroot, still no luck</p> 2008-03-11T03:12:56-04:0035784http://forums.silverlight.net//p/11057/35784.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>&nbsp;Can you post your server web.config and the client code which establish the proxy?</p> <p>The problem seems to be belong to endpoint address.&nbsp;</p> 2008-03-11T07:05:07-04:0035790http://forums.silverlight.net//p/11057/35790.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <font color="#0000ff" size="2"> <p>Here it is&nbsp;</p> &lt;</font><font color="#a31515" size="2">system.serviceModel</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">behaviors</font><font color="#0000ff" size="2">&gt;</p> &lt;</font><font color="#a31515" size="2">serviceBehaviors</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">behavior</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">ModulesBehavior</font><font size="2">&quot;</font><font color="#0000ff" size="2">&gt;</p> &lt;</font><font color="#a31515" size="2">serviceMetadata</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">httpGetEnabled</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">true</font><font size="2">&quot;</font><font color="#0000ff" size="2"> /&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">serviceDebug</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">includeExceptionDetailInFaults</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">false</font><font size="2">&quot;</font><font color="#0000ff" size="2"> /&gt;</p> &lt;/</font><font color="#a31515" size="2">behavior</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;/</font><font color="#a31515" size="2">serviceBehaviors</font><font color="#0000ff" size="2">&gt;</p> &lt;/</font><font color="#a31515" size="2">behaviors</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">services</font><font color="#0000ff" size="2">&gt;</p> &lt;</font><font color="#a31515" size="2">service</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">behaviorConfiguration</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">ModulesBehavior</font><font size="2">&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">Modules</font><font size="2">&quot;</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">endpoint</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">address</font><font color="#0000ff" size="2">=</font><font size="2">&quot;&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">binding</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">basicHttpBinding</font><font size="2">&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">contract</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">IModules</font><font size="2">&quot;</font><font color="#0000ff" size="2">&gt;</p> &lt;</font><font color="#a31515" size="2">identity</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">dns</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">localhost</font><font size="2">&quot;</font><font color="#0000ff" size="2"> /&gt;</p> &lt;/</font><font color="#a31515" size="2">identity</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;/</font><font color="#a31515" size="2">endpoint</font><font color="#0000ff" size="2">&gt;</p> &lt;</font><font color="#a31515" size="2">endpoint</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">address</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">mex</font><font size="2">&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">binding</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">mexHttpBinding</font><font size="2">&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">contract</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">IMetadataExchange</font><font size="2">&quot;</font><font color="#0000ff" size="2"> /&gt;</font><font color="#0000ff" size="2"> <p>&lt;/</font><font color="#a31515" size="2">service</font><font color="#0000ff" size="2">&gt;</p> &lt;/</font><font color="#a31515" size="2">services</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <p>&lt;/</font><font color="#a31515" size="2">system.serviceModel</font><font color="#0000ff" size="2">&gt;</font></p> <p><font color="#0000ff" size="2">and the client code</font></p> <font color="#0000ff" size="2"><font color="#2b91af" size="2">BasicHttpBinding</font><font color="#000000" size="2"> b = </font><font color="#0000ff" size="2">new</font><font color="#000000" size="2"> </font> <font color="#2b91af" size="2">BasicHttpBinding</font><font size="2"><font color="#000000">();</font></font></font><font size="2"> <p>ServiceReference1.</font><font color="#2b91af" size="2">ModulesClient</font><font size="2"> client = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">ModulesClient</font><font size="2">(b, </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">EndpointAddress</font><font size="2">(</font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Uri</font><font size="2">(</font><font color="#a31515" size="2">&quot;http://localhost:8082/WebSite1/Modules.svc&quot;</font><font size="2">)));</p> client.DoWorkCompleted &#43;= </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">EventHandler</font><font size="2">&lt;</font><font color="#2b91af" size="2">DoWorkCompletedEventArgs</font><font size="2">&gt;(client_DoWorkCompleted);</font><font size="2"> <p>client.DoWorkAsync();</p> <p>&nbsp;</p> <font size="2"></font><font color="#0000ff" size="2">void</font><font size="2"> client_DoWorkCompleted(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, </font><font color="#2b91af" size="2">DoWorkCompletedEventArgs</font><font size="2"> e)</font></font><font size="2"> <p>{</p> </font><font color="#0000ff" size="2">int</font><font size="2"> i = 0;</font><font size="2"> <p>}</p> </font> 2008-03-11T07:33:04-04:0035806http://forums.silverlight.net//p/11057/35806.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>Hello, your service use the port 8082. Then what's the port of the web site hosting the Silverlight application? If the port numbers are different, it's considered as cross domain. Does your IIS use the port 8082? By default it uses 80. Have you deployed both&nbsp;your service and Silverlight&nbsp;application on IIS, or are you using an ASP.NET test server? Put a policy file under <a href="file:///C:/Inetpub/wwwroot">C:\Inetpub\wwwroot</a> only affects IIS. It doesn't affect any ASP.NET test servers.</p> 2008-03-11T08:27:25-04:0035808http://forums.silverlight.net//p/11057/35808.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>the port number is set to 8082 and Use dynamic ports is set to false. it is not hosted in IIS. it is filesystem based</p> 2008-03-11T08:34:17-04:0035812http://forums.silverlight.net//p/11057/35812.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>Thus you should put your cross domain policy file under the root of your web service project.</p> 2008-03-11T08:47:45-04:0035818http://forums.silverlight.net//p/11057/35818.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>Here is a link to the project </p> <p><a href="http://cid-71b364b59919d1e8.skydrive.live.com/self.aspx/docs/Example2.rar">http://cid-71b364b59919d1e8.skydrive.live.com/self.aspx/docs/Example2.rar</a></p> <p>Can you tell me what I am doing wrong</p> 2008-03-11T09:07:40-04:0035850http://forums.silverlight.net//p/11057/35850.aspx/1?Re+Re+Re+calling+wcf+service+problemsRe: Re: Re: calling wcf service problems <p>&nbsp;I cannot download your *.rar file due to my company policy.&nbsp; If your service is located at <font color="#a31515" size="2">http://localhost:8082/WebSite1/Modules.svc, than the SVL page should be located there as well, e.g. </font><font color="#a31515" size="2">http://localhost:8082/WebSite1/TestPage.html if you don't put the cross domain config under WebSite1/</font></p> <p>HTH&nbsp;</p> 2008-03-11T10:21:28-04:0035860http://forums.silverlight.net//p/11057/35860.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>Well, looks like the ASP.NET test server maps the root folder to <a href="http://localhost:8082/WebSite1"> http://localhost:8082/WebSite1</a>. Thus the policy file is placed under <a href="http://localhost:8082/WebSite1"> http://localhost:8082/WebSite1</a>. This will not work. Sorry I can't figure out how to make ASP.NET test server to map the root folder to <a href="http://localhost:8082/">http://localhost:8082</a>. Can you use IIS instead? After I deployed your service to my IIS, and add the policy file to wwwroot folder, I've successfully called the service. Also note you must run your Silverlight application from http protocol. When creating a new Silverlight project, make sure to choose add a new web site. If you choose to just create a dynamic test page, your application will run from the file system.</p> 2008-03-11T10:33:05-04:0036521http://forums.silverlight.net//p/11057/36521.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>I am having the same problem, and tried to follow this thread to solve it. Not successful. My service is located at: C:\Dev\SilverlightApplication1\WcfService1\service1.svc with URL as <a href="http://localhost/WcfService1/service1.svc">http://localhost/WcfService1/service1.svc</a>. My IIS default web site is: <a href="http://localhost/">http://localhost/</a>, and it's mapped to C:\Inetpub\wwwroot. I created a policy file at: C:\Inetpub\wwwroot. And it can be accessed by <a href="http://localhost/crossdomain.xml">http://localhost/crossdomain.xml</a>&nbsp;as instructed by the Microsoft document. My SL client is running by WebDev.WebServer&nbsp;with&nbsp;a dynamic port, which is not my choice. It's created like that even&nbsp;when&nbsp;I selected web site option. Things just don't work. I get CrossDomainError every time.</p> 2008-03-12T22:30:53-04:0036536http://forums.silverlight.net//p/11057/36536.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>I also have been following this thread and still cannot call my web service from my SL2 Beta 1 app. I have a WCF service on a live server.</p> <p>I've changed the binding in web.config to basicHttpBinding and&nbsp;went into IIS and created a new&nbsp;&quot;Application&quot; on the server for&nbsp;the&nbsp;folder my service resides in. I also added crossdomain.xml and clientaccesspolicy.xml to both the root of my site and the webservice's folder. And in case you're wondering, the .svc URL loads fine in a browser (no errors).</p> <p>In my SL2 project I've added a service reference via the live url. It appeared to add fine.</p> <p>In my code I call: </p> <font size="2">Dim WithEvents ServerObject&nbsp;As </font><font color="#0000ff" size="2">New</font><font size="2"> Server_Samples.ServicesClient(</font><font color="#0000ff" size="2">New</font><font size="2"> System.ServiceModel.BasicHttpBinding, </font><font color="#0000ff" size="2">New</font><font size="2"> System.ServiceModel.EndpointAddress(</font><font color="#0000ff" size="2">New</font><font size="2"> Uri(</font><font color="#a31515" size="2">&quot;http://mylivesite.com/Service1/Services.svc&quot;</font><font size="2">)))</font><font size="2"> <p>ServerObject.MyFunctionAsync(Param1, </font><font color="#0000ff" size="2">Param2</font><font size="2">) ' this bombs out inside my proxy class's BeginMyFunction method</font></p> <p><font size="2">An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.dll but was not handled in user code</font></p> <p><font size="2">Additional information: [CrossDomainError]<br> Arguments:<br> Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See <a href="http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.30226.2&amp;File=System.ServiceModel.dll&amp;Key=CrossDomainError"> http://go.microsoft.com/fwlink/?linkid=106663&amp;Version=2.0.30226.2&amp;File=System.ServiceModel.dll&amp;Key=CrossDomainError</a><br> </font></p> <p><font size="2">Any help would be greatly appreciated! I've been trying everything I can think of for the majority of the day and still can't get it to work.</font></p> <p><font size="2">fyi: I also tried to hit this exact same service from a WinForms app and it worked fine.</p> </font> 2008-03-12T23:12:00-04:0036572http://forums.silverlight.net//p/11057/36572.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>&nbsp;I am having the exact same error.&nbsp; This seems to be a widespread thing?<br> </p> 2008-03-13T01:22:23-04:0036607http://forums.silverlight.net//p/11057/36607.aspx/1?Re+Re+calling+wcf+service+problemsRe: Re: calling wcf service problems <p>I can run my app in the VS2008 testing server and it works ok in IIS.</p> <p>However, is not working when accessed from a remote machine.</p> <p>I have the crossdomain file and the ports are open for web.</p> <p>I must have something missin'</p> 2008-03-13T03:00:20-04:0036939http://forums.silverlight.net//p/11057/36939.aspx/1?calling+wcf+service+problemscalling wcf service problems <p>The webservice was not properly setup on the Silverlight app.</p> <p>I could not find an easy way to fix than to open the Web Service References folder and scan and change every file for the webservice's url.</p> <p>&nbsp;</p> <p>I didn't work when:</p> <p>trying to remove the service and readd it using the public ip address.(previously using the local machine name)</p> 2008-03-13T23:36:39-04:00