<?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>Development Blog &#187; Medium Trust</title>
	<atom:link href="http://blog.yeticode.co.uk/tag/medium-trust/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yeticode.co.uk</link>
	<description>John Tindell's Blog For Development Related Things</description>
	<lastBuildDate>Mon, 09 Jan 2012 01:21:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Running NHibernate in Medium Trust</title>
		<link>http://blog.yeticode.co.uk/2010/03/running-nhibernate-in-medium-trust/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-nhibernate-in-medium-trust</link>
		<comments>http://blog.yeticode.co.uk/2010/03/running-nhibernate-in-medium-trust/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 23:34:50 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Development Log]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Medium Trust]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blog.yeticode.co.uk/?p=636</guid>
		<description><![CDATA[After deploying a NHibernate to a shared host I started running into a number of issues. Whilst developing we were running in full trust not in medium trust whilst the majority of shared hosts use. After hours and hours of searching I finally come across a post on the Castle Project mailing list which detailed [...]]]></description>
			<content:encoded><![CDATA[<p>After deploying a NHibernate to a shared host I started running into a number of issues. Whilst developing we were running in full trust not in medium trust whilst the majority of shared hosts use. After hours and hours of searching I finally come across a <a href="http://groups.google.com/group/castle-project-users/browse_thread/thread/2451ef352523865f?hl=en&#038;pli=1">post</a> on the <a href="http://groups.google.com/group/castle-project-users?hl=en">Castle Project mailing list</a> which detailed how to get a nhibernate working under medium trust. Here is the steps I followed to get it working.</p>
<p>I am using NHibernate 2.1.2 and C# .NET 3.5 in Visual Studio 2008.</p>
<h3>Step 1</h3>
<p>Download Castle.Core from gitbhub<br />
git://github.com/castleproject/Castle.Core.git</p>
<p><a href="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-1.png" rel="lightbox[636]"><img src="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-1.png" alt="" title="Screenshot-1" width="489" height="337" class="alignnone size-full wp-image-647" /></a></p>
<h3>Step 2</h3>
<p>Enable Castle to allow partially trusted callers.<br />
Open buildscripts/CommonAssemblyInfo.cs and enable the library to enable partially trusted callers</p>
<p><a href="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-2.png" rel="lightbox[636]"><img src="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-2.png" alt="" title="Screenshot-2" width="589" height="286" class="alignnone size-full wp-image-654" /></a></p>
<h3>Step 3</h3>
<p>Disable generation of debug information for the projects Castle.Core and Castle.DynamicProxy.<br />
<a href="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-4.png" rel="lightbox[636]"><img src="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-4-300x175.png" alt="" title="Screenshot-4" width="300" height="175" class="alignnone size-medium wp-image-657" /></a></p>
<h3>Step 4</h3>
<p>Build the projects</p>
<h3>Step 5</h3>
<p>Download Nhibernate source code from source forge.</p>
<p><a href="http://sourceforge.net/projects/nhibernate/files/" rel="nofollow">http://sourceforge.net/projects/nhibernate/files/</a></p>
<h3>Step 6</h3>
<p>Open Nhibernate.Everything.sln and update the references for the NHibernate.ByteCode.Castle project so that the references for Castle.Core and Castle.DynamicProxy2 are the libraries build in step 4. Disable generation of debug information for the projects NHibernate, Iesi.Collections and NHibernate.ByteCode.Castle, similar to what was done in step 3.</p>
<p><a href="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-5.png" rel="lightbox[636]"><img src="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-5-300x187.png" alt="" title="Screenshot-5" width="300" height="187" class="alignnone size-medium wp-image-661" /></a></p>
<h3>Step 7</h3>
<p>Copy the outputted library files from NHibernate.ByteCode/bin/Release to your shared libs folder of your project.</p>
<p><a href="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-6.png" rel="lightbox[636]"><img src="http://blog.yeticode.co.uk/wp-content/uploads/2010/03/Screenshot-6-300x225.png" alt="" title="Screenshot-6" width="300" height="225" class="alignnone size-medium wp-image-663" /></a></p>
<h3>Step 8</h3>
<p>Update the references in your project to point to the new libraries. Next turn off reflection optimization. This needs to be done in code before you create the configuration object. Configuring this in the hibernate.cfg.xml does not work. Update all your projects assemblies to set allow partially trusted callers, similar to step 2. Update your web.config to set requirePermission=&#8221;false&#8221; in the nhibernate section delceration</p>
<pre class="c-sharp" name="code">
NHibernate.Cfg.Environment.UseReflectionOptimizer = false;
Configuration = new Configuration();
Configuration.Configure();
</pre>
<pre name="code" class="xml">
<configSections>
<section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
</pre>
<p>You can now run your site in medium trust using lay loading.</p>
<h2>Links</h2>
<ul>
<li><b>msysgit</b> &#8211; <a href="http://code.google.com/p/msysgit/" rel="nofollow">http://code.google.com/p/msysgit/</a></li>
<li><b>TortoiseGit</b> &#8211; <a href="http://code.google.com/p/tortoisegit/" rel="nofollow">http://code.google.com/p/tortoisegit/</a></li>
<li><b>NHibernate</b> &#8211; <a href="http://nhforge.org/" rel="nofollow">http://nhforge.org/</a></li>
<li><b>Castle.Core Source</b> &#8211; <a href="http://github.com/castleproject/" rel="nofollow">http://github.com/castleproject/</a></li>
<li><b>NHibernate Source</b> &#8211; <a href="http://sourceforge.net/projects/nhibernate/files/" rel="nofollow">http://sourceforge.net/projects/nhibernate/files/</a></li>
</ul>
<h2>Related Reading</h2>
<table>
<tr>
<td>
<a style="display:inline-block;" href="http://www.amazon.co.uk/gp/product/1932394923?ie=UTF8&#038;tag=yetiblog-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1932394923"><img border="0" src="http://static.yeticode.co.uk/blog/images/nhibernate.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=yetiblog-21&#038;l=as2&#038;o=2&#038;a=1932394923" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</td>
<td>
<a style="display:inline-block;" href="http://www.amazon.co.uk/gp/product/0321228103?ie=UTF8&#038;tag=worldoverride-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0321228103"><img border="0" src="http://static.yeticode.co.uk/blog/images/open_source_dot_net.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=worldoverride-21&#038;l=as2&#038;o=2&#038;a=0321228103" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;display:inline-block;" />
</td>
<td>
<a style="display:inline-block;" href="http://www.amazon.co.uk/gp/product/1847198902?ie=UTF8&#038;tag=worldoverride-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1847198902"><img border="0" src="http://static.yeticode.co.uk/blog/images/nhibernate_2.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=worldoverride-21&#038;l=as2&#038;o=2&#038;a=1847198902" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</td>
</tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://blog.yeticode.co.uk/2010/03/running-nhibernate-in-medium-trust/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

