<?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>The Iterator &#187; wcf</title>
	<atom:link href="http://theiterator.com/tag/wcf/feed/" rel="self" type="application/rss+xml" />
	<link>http://theiterator.com</link>
	<description>This is my blog. There are many like it, but this one is mine.</description>
	<lastBuildDate>Thu, 10 Dec 2009 06:13:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ninject &amp; WCF</title>
		<link>http://theiterator.com/2009/10/ninject-wcf/</link>
		<comments>http://theiterator.com/2009/10/ninject-wcf/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 11:05:35 +0000</pubDate>
		<dc:creator>theiterator</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[ninject]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://theiterator.com/?p=92</guid>
		<description><![CDATA[Ninject relies on an HttpModule when instantiating the Kernel with OnePerRequestBehavior. WCF hosting infrastructure intercepts requests when the PostAuthenticateRequest is raised and doesn&#8217;t return processing to the ASP.NET HTTP pipeline. Ninject&#8217;s OnePerRequestModule only registers an event handler on the EndRequest event and thus isn&#8217;t ran on requests to a WCF service.
A quick fix for this [...]]]></description>
			<content:encoded><![CDATA[<p>Ninject relies on an HttpModule when instantiating the Kernel with OnePerRequestBehavior. WCF hosting infrastructure intercepts requests when the PostAuthenticateRequest is raised and doesn&#8217;t return processing to the ASP.NET HTTP pipeline. Ninject&#8217;s OnePerRequestModule only registers an event handler on the EndRequest event and thus isn&#8217;t ran on requests to a WCF service.</p>
<p>A quick fix for this is to enable AspNetCompatibilityMode on the WCF hosting infrastructure. In your web.config, add the following tag under your &lt;system.serviceModel&gt; declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serviceHostingEnvironment</span> <span style="color: #000066;">aspNetCompatibilityEnabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>You also have to decorate your .svc class with the following attribute:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>AspNetCompatibilityRequirements<span style="color: #000000;">&#40;</span>RequirementsMode <span style="color: #008000;">=</span> AspNetCompatibilityRequirementsMode.<span style="color: #0000FF;">Allowed</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></pre></div></div>

<p>I don&#8217;t know if this is an ideal solution however, and if it has any negative effects on performance etc. More elegant <a href="http://www.ohloh.net/p/ninject-extensions-wcf">solutions</a> seem to be available. More information on AspNetCompatibilityMode is available on <a href="http://msdn.microsoft.com/en-us/library/aa702682.aspx">MSDN</a>.</p>
<p class="bookmark-me"><a title="technorati.com" href="http://www.technorati.com/faves?add=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/technorati.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;title=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/delicious.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="stumbleupon.com" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;title=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/stumbleupon.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="digg.com" href="http://digg.com/submit?url=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;title=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/digg.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="www.facebook.com" href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;t=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/facebook.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="reddit.com" href="http://reddit.com/submit?url=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;title=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/reddit.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> <a title="twitthis.com" href="http://twitthis.com/twit?url=http%3A%2F%2Ftheiterator.com%2F2009%2F10%2Fninject-wcf%2F&amp;title=Ninject+%26%23038%3B+WCF"><img src="http://theiterator.com/wp-content/plugins/bookmark-me/images/twitter.png" style="margin:0;border:0;padding:0" alt="bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://theiterator.com/2009/10/ninject-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
