I read this post about debugging Silverlight and it felt like too much of hack. So I thought I would present my far superior (I'm kidding here, I do think it's neater, though) solution.
Assuming that you have followed the tutorial on the SDK or on this page, you should have a file called SilverlightUtilty.cs and in this file you will have a method called GetSoapService. All you need to do is make use of the #if directive.
#if !DEBUG Uri serviceUrl = CombineUrl(GetServerBaseUrl(), "/XRMServices/2011/Organization.svc/web"); #else Uri serviceUrl = new Uri("http://localhost/testorg/XRMServices/2011/Organization.svc/web"); #endif
You also need to ensure that you only use the Debug build for your development environment and Release for production, but you are doing that already, right?. At any rate, here is a step by step guide:
- Set up Silverlight project following this tutorial.
- Change code in SilverlightUtility.cs as described above.
- Create clientaccesspolicy.xml file:
<?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>
- Copy clientaccesspolicy.xml to the website directory (normally c:\Program Files\Microsoft Dynamics CRM\CRMWeb\).
- Debug from Visual Studio.
- Ensure that you compile it as Release before you deploy it to other environments.
Uri serviceUrl = new Uri("http://localhost/org/XRMServices/2011/Organization.svc/web");
No comments:
Post a Comment