nhibernatecastle-activerecordcastlepartial-trust

Compiling Castle.ActiveRecord to allow partial trust?


How can I build Castle.Core, Castle.ActiveRecord and NHibernate to allow partial trust? There are plenty of resources on the web showing how this can be done, however every site I found says to use nant build -D:assembly.allow-partially-trusted-callers=true to build each assembly. When I look at the Castle.Core trunk here there is no *.build file.

How can this be accomplished? I am using .NET 3.5 . This is not a web application.

Edit: We're using NHibernate 2.1.2GA (latest stable version, I believe). The problem with the instructions given below is that it looks like their referring to building Castle.Core and Castle.ActiveRecord from trunk. Trunk appears to be requiring NHibernate 3.0.0 which doesn't match our version.

Solution

Almost all of my tweaks were done in the Security tab under project properties.

Also, since the application and SQL Server are residing under different domains I had to set my connection string to include the database server domain. So my original connection string data source had to go from "Data Source=DB_SERVER" to "Data Source=DB_SERVER.DOMAIN".

Lastly, I had to set requirePermission="false" on all of my configuration sections. My configSections ended up like this:

  <configSections>
    <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" requirePermission="false"/>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" requirePermission="false"/>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    <section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
  </configSections>

After everything was said and done I was successfully able to publish this application on a file share from a different domain and have the users install the application with no issues. Applying these steps to our other applications and using our newly compiled assemblies also worked like a charm.


Solution

  • You'll need MSBuild 4.0, the nant build scripts have since long gone.

    If you've got Visual Studio 2010, open the Visual Studio 2010 Command Prompt otherwise make sure you use MSBuild from the .NET 4.0 framework.

    Given you've got NHibernate built for APTCA (nant -D:-D:assembly.allow-partially-trusted-callers=true works thre)