Friday, October 28, 2011

Cross domain policy for silverlight to access a WCF Service

Today, I'm posting about an issue which I faced when making a WCF Service to be accessible across different domains. And this was for a silver-light chat application. The chat application didn't work for me, and it threw me the below error when I debugged.
"An error occurred while trying to make a request to URI http://SampleSite/Chat Service.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."
After going through the MSDN, I was able to solve the issue.

"To enable a Silverlight control to access a service in another domain, the service must explicitly opt-in to allow cross-domain access. By opting-in, a service states that the operations it exposes can safely be invoked by a Silverlight control, without potentially damaging consequences to the data that the service stores.

Silverlight 4 supports two different mechanisms for services to opt-in to cross-domain access:

  • Place a clientaccesspolicy.xml file at the root of the domain where the service is hosted to configure the service to allow cross-domain access.

  • Place a valid crossdomain.xml file at the root of the domain where the service is hosted. The file must mark the entire domain public. Silverlight supports a subset of the crossdomain.xml schema. "
                                                                                                                      - MSDN [1]

This is even clear when you use the nikhilk's Web development helper with ie( can view request, response details) and check out the request [2] (check video) . It searches for those two files.

Here are the two files that are needed.

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


<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "">
  <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>

Save both these files to the root of the domain where the service is hosted. If, for example, the service is hosted in, then the file must be located at Thanks to MSDN!




Check out the above video [2]  by Tim Heuer . It was really helpful!!!

Intellisense not working on MVC

Recently I had an opportunity to work on an Microsoft MVC 2 project. For me, the intellisense didn't work on the MVC web pages.

I also got the below run time error because of using the log4net dll. However, the reference to the dll was correct.

"ASP.NET runtime error: Could not load file or assembly 'log4net, Version=, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))".


The Solution is to clear the "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\" files. It works now! Cheers!!!

Monday, January 17, 2011

onmouseover="'hand'" not working in Firefox

hi all, this is a small CSS issue which I came across today, and was able to fix it out. This code below works wells with IE, but not with Firefox on mouse-over of an image/ div .

< div >
< asp:Image ID="Image1" runat="server" ImageUrl="~/Images/chat.png" onmouseover="'hand' " / >
< /div >

The solution is to replace "hand" with "pointer".

< div >
< asp:Image ID="Image1" runat="server" ImageUrl="~/Images/chat.png" onmouseover="'pointer' " / >
< /div >
cause, The standard is "pointer", not "hand". "hand" is for IE 4/5.

Lushanthan. S