I can't debug WCF Silverlight 2.0
Last post 04-30-2008 11:32 AM by spinoza. 8 replies.
Sort Posts:
04-28-2008 4:31 PM
I can't debug WCF Silverlight 2.0
An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.dll but was not handled in user codeAdditional information: [CrossDomainError]The above is the error I get when I hit f5. The first stop of the debugger is in the Reference.cs file at

System.IAsyncResult _result = base.BeginInvoke("getKeyWord", _args, callback, asyncState);

Which returns null.

That is not where my breakpoint is. My break point is on a line in the page.xaml.cs.

My "project" consists of a solution with a silverlight application and a web site containing a WCF service. The silverlight application is on my dev server here at the office and the web site and web service are ... on the web! There is a policy file at the root of the web domain where the test page is. The combination behaves great, does what I want but I can't debug it to my satisfaction. The service reference in the silverlight app refers to the WCF service and it all works just peachy but why can't I set breakpoints and track whats going on.

Thanks

 

Spin 

 

spinoza

Joined on 12-20-2006
Posts 13
04-29-2008 2:04 AM
Re: I can't debug WCF Silverlight 2.0

spinoza:
There is a policy file at the root of the web domain where the test page is. 
 

Your web service is at that place too?  You need to put the policy file at the root of web domain where web service is located. If you configure correctly, you won't get the cross-domain error.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-29-2008 6:10 PM
Re: I can't debug WCF Silverlight 2.0

Michael:

My webservice is in the same directory as my policy file. Both are at the root of the domain already? Any other suggestions.

thanks

Spin

spinoza

Joined on 12-20-2006
Posts 13
04-29-2008 11:26 PM
Re: I can't debug WCF Silverlight 2.0

spinoza:
My webservice is in the same directory as my policy file. Both are at the root of the domain already? Any other suggestions.
 

Can you give me the project structure?

Like I said in this post

Let's say you have three projects.

  • One project is the Silverlight project that is gonna invoke the service or page or something.    (e.g. SLTests1)
  • The other one is the ASP.NET project that is hosted Silverlight content.   (e.g. WebApplication1 )
  • Another one is the PHP or ASP.NET project that is gonna receive the POST request from Silverlight.

SLTests1
--- Page.xaml
----App.xaml

WebApplication1
---- [ClientBin]
--------------SLTests1.xap
----SLTests1TestPage.aspx

့့့h့ttp://localhost   ( NOT http://localhost/yourservice/)
----- clientaccesspolicy.xml
----- crossdomain.xml

If you are testing with VS Development web server, it wont work because we can't put our crossdomain under http://localhost:50782/. Whenever we run the project, those xml files will go under "http://localhost:50782/SilverlightApplication5_Web/".

If you want to do POST request, create the Virtual Directory in IIS. then, you can put those XML files under wwwroot.

 The best way to do is that you should put the WCF in ASP.NET project. And use the static port instead of dynamic one.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-30-2008 9:57 AM
Re: I can't debug WCF Silverlight 2.0

Michael: 

My structure is

SLTests1
--- Page.xaml
----App.xaml

WebApplication1

-----crossdomain.xml 
----SLTests1TestPage.aspx

---- [ClientBin]
--------------SLTests1.xap


 

 

spinoza

Joined on 12-20-2006
Posts 13
04-30-2008 10:19 AM
Re: I can't debug WCF Silverlight 2.0

spinoza:

WebApplication1

-----crossdomain.xml 
----SLTests1TestPage.aspx

 

Yes. That's the problem. You can't put this XML file under WebApplication. You have to put it in wwwroot. If you are using VS Development server,  you can't use crossdomain.xml file. That's a limitation. You have to use IIS for that.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-30-2008 10:31 AM
Re: I can't debug WCF Silverlight 2.0

Hmm, sorry I'm confused. I have a project consisting of a website the project is called WebApplication1 the content of that is a web site serverd by IIS as reached at http://www.MySite.com The crossdomain.xml is at http://www.MySite.com/crossdomain.xml.

What am I missing?

Spin

spinoza

Joined on 12-20-2006
Posts 13
04-30-2008 11:18 AM
Re: I can't debug WCF Silverlight 2.0

spinoza:

The crossdomain.xml is at http://www.MySite.com/crossdomain.xml.

What am I missing?

 

Oh. Okay.

You wrote like below

WebApplication1

---------crossdomain.xml

So, I thought your xml will be at http://yoursite.com/WebApplication1/crossdomain.xml.

What do you have in crossdomain.xml? The URL of web service that you have in Silverlight is correct? You should point to the webservice that you host in IIS.  Normally, the url is hard-coded in disco file under Service Reference.  

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-30-2008 11:32 AM
Re: I can't debug WCF Silverlight 2.0

Sorry "my bad" as they say. I am using this crossdomain.xml

<?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>

spinoza

Joined on 12-20-2006
Posts 13