<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joel Hainley &#187; .NET</title>
	<atom:link href="http://www.joelhainley.com/index.php/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joelhainley.com</link>
	<description>my thoughts and adventures</description>
	<lastBuildDate>Mon, 19 Dec 2011 19:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Silverlight : Communication Exception was unhandled by user code</title>
		<link>http://www.joelhainley.com/index.php/2009/02/04/silverlight-communication-exception-was-unhandled-by-user-code/</link>
		<comments>http://www.joelhainley.com/index.php/2009/02/04/silverlight-communication-exception-was-unhandled-by-user-code/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 18:13:20 +0000</pubDate>
		<dc:creator>joelhainley</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[clientaccesspolicy.xml]]></category>

		<guid isPermaLink="false">http://www.joelhainley.com/?p=124</guid>
		<description><![CDATA[Ran into the following error the other day :
An error occurred while trying to make a request to URI &#8216;http://localhost/T2WS/AdminServices.asmx&#8217;. 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 [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into the following error the other day :</p>
<blockquote><p>An error occurred while trying to make a request to URI &#8216;http://localhost/T2WS/AdminServices.asmx&#8217;. 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. Please see the inner exception for more details.</p></blockquote>
<p>The error message was self-explanatory but it didnt&#8217; solve the problem. I had my cross domain file setup appropriately and yet I was still receiving the error. As seen below the stack trace didn&#8217;t offer much help either:</p>
<blockquote><p>System.ServiceModel.CommunicationException was unhandled by user code<br />
Message=&#8221;An error occurred while trying to make a request to URI &#8216;http://localhost/T2WS/AdminServices.asmx&#8217;. 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. Please see the inner exception for more details.&#8221;<br />
StackTrace:<br />
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)<br />
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)<br />
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)<br />
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)<br />
at T2SL.T2AdminService.AdminServicesSoapClient.AdminServicesSoapClientChannel.EndgetAccountList(IAsyncResult result)<br />
at T2SL.T2AdminService.AdminServicesSoapClient.T2SL.T2AdminService.AdminServicesSoap.EndgetAccountList(IAsyncResult result)<br />
at T2SL.T2AdminService.AdminServicesSoapClient.EndgetAccountList(IAsyncResult result)<br />
at T2SL.T2AdminService.AdminServicesSoapClient.OnEndgetAccountList(IAsyncResult result)<br />
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)<br />
InnerException: System.Security.SecurityException<br />
Message=&#8221;"<br />
StackTrace:<br />
at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)<br />
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)<br />
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)<br />
InnerException: System.Security.SecurityException<br />
Message=&#8221;Security error.&#8221;<br />
StackTrace:<br />
at System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)<br />
at System.Net.BrowserHttpWebRequest.&lt;&gt;c__DisplayClass5.&lt;EndGetResponse&gt;b__4(Object sendState)<br />
at System.Net.AsyncHelper.&lt;&gt;c__DisplayClass2.&lt;BeginOnUI&gt;b__0(Object sendState)<br />
InnerException:</p></blockquote>
<p>Still no luck, i spent some time fiddling with the clientaccesspolicy.xml file but it didn&#8217;t seem to be the problem. After a bit of digging and avoiding the obvious, it finally hit me right between the eyes. I had setup the Silverlight project to be the startup and it was running the file locally, instead of running it through the web project I had setup to wrap Silverlight with.</p>
<p>Once I changed the startup project to the Web project and the file to the Silverlight testpage everything worked just fine and dandy except that the Silverlight project wasn&#8217;t updating. Looking through the Silverlight project properties I was able to point the build for the Silverlight &#8220;executable&#8221; to the Web project&#8217;s ClientBin directory and everything fell into place.</p>
<p>I just mention this hear because I&#8217;m sure I&#8217;ll forget how I solved this problem the next time I run into it. <img src='http://www.joelhainley.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.joelhainley.com/index.php/2009/02/04/silverlight-communication-exception-was-unhandled-by-user-code/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

