<?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>Martijn Boland &#187; Lucene.Net</title>
	<atom:link href="http://blogs.taiga.nl/martijn/tag/lucene-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.taiga.nl/martijn</link>
	<description>New adventures in .NET</description>
	<lastBuildDate>Tue, 27 Apr 2010 20:51:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>New adventures under medium trust</title>
		<link>http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-trust/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-trust/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:55:33 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[Castle]]></category>
		<category><![CDATA[Cuyahoga]]></category>
		<category><![CDATA[Lucene.Net]]></category>
		<category><![CDATA[Medium Trust]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-trust/</guid>
		<description><![CDATA[Many web hosting companies only allow ASP.NET applications to run under medium trust. This has been a major drawback for Cuyahoga because it required full trust (or better: some libraries require full trust). This has already caused some nasty surprises when people deployed their site to the host to find out it would not run. [...]]]></description>
			<content:encoded><![CDATA[<p>Many web hosting companies only allow ASP.NET applications to run under medium trust. This has been a major drawback for <a href="http://cuyahoga-project.org">Cuyahoga</a> because it required full trust (or better: some libraries require full trust). This has already caused some nasty surprises when people deployed their site to the host to find out it would not run.</p>
<p>Well, I can finally say that Cuyahoga 2.0 will work under medium trust!</p>
<h3>Castle DynamicProxy</h3>
<p>Last week, someone mentioned on the <a href="http://castle-project.org" target="_blank">Castle</a> <a href="http://groups.google.com/group/castle-project-users" target="_blank">users list</a> that <a href="http://www.castleproject.org/dynamicproxy/index.html" target="_blank">DynamicProxy</a> was supposed to work under medium trust and this immediately triggered me. DynamicProxy had always been the key part that prevented Cuyahoga, <a href="http://nhforge.org/Default.aspx" target="_blank">NHibernate</a>, and lots of other software from running under medium trust because it generates assemblies on the fly and that’s not allowed (at least pre-NET 2.0 SP1).</p>
<p>So, I checked out a fresh version of the Castle trunk, built it with AllowPartiallyTrustedCallers and copied the assemblies to Cuyahoga that was set to run under medium trust.    <br />Unfortunately, still no luck. The dreaded SecurityException showed its yellow screen, but instead of giving up immediately, I took a deep breath and started digging the DynamicProxy sources. The solution was a simple one: DynamicProxy calls <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.assemblybuilder.definedynamicmodule.aspx" target="_blank">AssemblyBuilder.DefineDynamicModule</a> and used the overload that generates debug symbols. Changing that to not generate the debug symbols anymore made it work under medium trust! I send a patch to the Castle guys and lets hope it can be incorporated. This allows NHibernate to run under medium trust without turning off <a href="http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx" target="_blank">lazy-load on class mappings</a> or using a special <a href="http://blechie.com/WPierce/archive/2008/02/17/Lazy-Loading-with-nHibernate-Under-Medium-Trust.aspx" target="_blank">proxy generator</a>.</p>
<p>One caveat: the Castle trunk requires .NET 3.5, so we can’t fix it for the 1.6.x branch of Cuyahoga which is .NET 2.0. </p>
<h3>Lucene.Net</h3>
<p>Second, <a href="http://incubator.apache.org/lucene.net/" target="_blank">Lucene.Net</a> didn’t work under medium trust and boy, that was easy to fix: a single call was made to a relative file path, which is not allowed. Changed that to use the full path and it worked. <a href="http://issues.apache.org/jira/browse/LUCENENET-169" target="_blank">Submitted a patch</a> and I hope they will accept it.</p>
<h3></h3>
<h3>Cuyahoga</h3>
<p>So, with the libraries working under medium trust, I was ready to roll, at least I thought so. It appeared however that Cuyahoga also did some nasty things that are not allowed under medium trust, such as requesting a HttpModule instance from the appdomain and some file access outside the application root. Fortunately these were easy fixes and now I have everything working just fine under medium trust.</p>
<p>I think, I’ll leave medium trust turned on in the development version to signal issues in an early state.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-trust/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
