Quick Tip: Cross Domain Policy Problems With Web Services / Silverlight

More a note to myself more than anything. If you have a Silverlight application that is invoked from a domain and then making calls to a SharePoint web service in a different domain, you may encounter the following error:

An error occurred while trying to make a request to URI ‘http://sharepoint/stuff/morestuff/superservice.svc’. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

The fix is to place copies of the crossdomain.xml and clientaccesspolicy.xml files in the root application folder. Works fine afterwards.


SPQuery Based Joins In SharePoint 2010

While working with a client today on some SharePoint 2010 code, the requirement can up to do some query based joins. I hadn’t done this before in SP 2010, but it’s pretty sweet. The only way I have gotten around it in previous versions was converting the list data into data tables and then working with it in that format. Natively working with it is a whole lot less code, whole lot less complicated too. Even for permanent join type stuff, you can use projected fields which is really nice.

So, what’s it look like? Consider the following snippet:



Pretty easy!