using lastest version of castle.dynamicproxy with nhibernate

70 views
Skip to first unread message

Gitted

unread,
Dec 4, 2009, 11:58:28 AM12/4/09
to Castle Project Users
I tried using the lastest version of castle.dynamic proxy but it seems
there are API changes and I just don't want to go there myself :)

Is this planned soon?

if not, or in the meantime, I can't find the castle.dynamic build used
in the current nhibernate release ?

the subversion repo also seems to have /trunk.

Jonathon Rossi

unread,
Dec 4, 2009, 12:15:58 PM12/4/09
to castle-pro...@googlegroups.com
IIRC NHibernate's current release is using DynamicProxy 2.1 RTM which should be in the NHibernate zip file downloadable from sourceforge.


--

You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.





--
Jono

Krzysztof Koźmic

unread,
Dec 4, 2009, 12:17:31 PM12/4/09
to castle-pro...@googlegroups.com
yeah,

provider for Castle will be updated soon.

Jonathon Rossi wrote:
> IIRC NHibernate's current release is using DynamicProxy 2.1 RTM which
> should be in the NHibernate zip file downloadable from sourceforge.
>
> On Sat, Dec 5, 2009 at 2:58 AM, Gitted <sahme...@gmail.com
> <mailto:sahme...@gmail.com>> wrote:
>
> I tried using the lastest version of castle.dynamic proxy but it seems
> there are API changes and I just don't want to go there myself :)
>
> Is this planned soon?
>
> if not, or in the meantime, I can't find the castle.dynamic build used
> in the current nhibernate release ?
>
> the subversion repo also seems to have /trunk.
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Castle Project Users" group.
> To post to this group, send email to
> castle-pro...@googlegroups.com
> <mailto:castle-pro...@googlegroups.com>.
> To unsubscribe from this group, send email to
> castle-project-u...@googlegroups.com
> <mailto:castle-project-users%2Bunsu...@googlegroups.com>.

Gitted

unread,
Dec 4, 2009, 12:42:59 PM12/4/09
to Castle Project Users
So are you both saying the opposite things here? :)

On Dec 4, 12:17 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:
> yeah,
>
> provider for Castle will be updated soon.
>
> Jonathon Rossi wrote:
> > IIRC NHibernate's current release is using DynamicProxy 2.1 RTM which
> > should be in the NHibernate zip file downloadable from sourceforge.
>

Krzysztof Koźmic

unread,
Dec 4, 2009, 12:45:58 PM12/4/09
to castle-pro...@googlegroups.com
no,

Current NH uses DP 2.1 but will update soon.

Gitted

unread,
Dec 4, 2009, 12:49:51 PM12/4/09
to Castle Project Users
Thanks, currently I am stuck because of medium trust issues at
rackspacecloud sites.

Exception Details: System.Security.SecurityException: That assembly
does not allow partially trusted callers.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: That assembly does not allow partially trusted
callers.]
Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
String strongAssemblyName, String strongModulePath, String
weakAssemblyName, String weakModulePath) +0
Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)
+35
Castle.DynamicProxy.ProxyGenerator..ctor() +38
NHibernate.ByteCode.Castle.ProxyFactory..cctor() +49


This is the web.config they gave for testing, although it works
locally so not sure if this "test" web.config is of any use!

<!-- medium-trust testing -->

<mscorlib>
<security>
<policy>
<PolicyLevel version="1">
<SecurityClasses>
<SecurityClass Name="AllMembershipCondition"
Description="System.Security.Policy.AllMembershipCondition, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="AspNetHostingPermission"
Description="System.Web.AspNetHostingPermission, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="ConfigurationPermission"
Description="System.Configuration.ConfigurationPermission,
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
<SecurityClass Name="DnsPermission"
Description="System.Net.DnsPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="EnvironmentPermission"
Description="System.Security.Permissions.EnvironmentPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FileIOPermission"
Description="System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="FirstMatchCodeGroup"
Description="System.Security.Policy.FirstMatchCodeGroup, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="IsolatedStorageFilePermission"
Description="System.Security.Permissions.IsolatedStorageFilePermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="NamedPermissionSet"
Description="System.Security.NamedPermissionSet"/>
<SecurityClass Name="PrintingPermission"
Description="System.Drawing.Printing.PrintingPermission,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
<SecurityClass Name="SecurityPermission"
Description="System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SmtpPermission"
Description="System.Net.Mail.SmtpPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SqlClientPermission"
Description="System.Data.SqlClient.SqlClientPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="StrongNameMembershipCondition"
Description="System.Security.Policy.StrongNameMembershipCondition,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UIPermission"
Description="System.Security.Permissions.UIPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UnionCodeGroup"
Description="System.Security.Policy.UnionCodeGroup, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="UrlMembershipCondition"
Description="System.Security.Policy.UrlMembershipCondition, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="WebPermission"
Description="System.Net.WebPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="ZoneMembershipCondition"
Description="System.Security.Policy.ZoneMembershipCondition, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="ReflectionPermission"
Description="System.Security.Permissions.ReflectionPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="OleDbPermission"
Description="System.Data.OleDb.OleDbPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="OdbcPermission"
Description="System.Data.Odbc.OdbcPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<SecurityClass Name="SocketPermission"
Description="System.Net.SocketPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</SecurityClasses>
<NamedPermissionSets>
<PermissionSet class="NamedPermissionSet" version="1"
Unrestricted="true" Name="FullTrust" Description="Allows full access
to all resources"/>
<PermissionSet class="NamedPermissionSet" version="1"
Name="Nothing" Description="Denies all resources, including the right
to execute"/>
<PermissionSet class="NamedPermissionSet" version="1"
Name="ASP.Net">
<IPermission class="AspNetHostingPermission" version="1"
Level="Medium"/>
<IPermission class="ConfigurationPermission" version="1"
Unrestricted="true"/>
<IPermission class="DnsPermission" version="1"
Unrestricted="true"/>
<IPermission class="EnvironmentPermission" version="1"
Read="TEMP;TMP;USERNAME;OS;COMPUTERNAME"/>
<IPermission class="FileIOPermission" version="1"
Read="$AppDir$" Write="$AppDir$" Append="$AppDir$"
PathDiscovery="$AppDir$"/>
<IPermission class="IsolatedStorageFilePermission"
version="1" Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"/>

<IPermission class="PrintingPermission" version="1"
Level="DefaultPrinting"/>

<IPermission class="SecurityPermission" version="1"
Flags="Assertion, Execution, ControlThread, ControlPrincipal,
RemotingConfiguration"/>
<IPermission class="SmtpPermission" version="1"
Access="ConnectToUnrestrictedPort"/>
<IPermission class="SqlClientPermission" version="1"
Unrestricted="true"/>
<IPermission class="WebPermission" version="1"
Unrestricted="true"/>
<IPermission class="OleDbPermission" version="1"
Unrestricted="true"/>
<IPermission class="OdbcPermission" version="1"
Unrestricted="true"/>
<IPermission class="SocketPermission" version="1"
Unrestricted="true" />
<IPermission class="ReflectionPermission" version="1"
Unrestricted="true"/>
</PermissionSet>
</NamedPermissionSets>
<CodeGroup class="FirstMatchCodeGroup" version="1"
PermissionSetName="Nothing">
<IMembershipCondition class="AllMembershipCondition"
version="1"/>
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="ASP.Net">
<IMembershipCondition class="UrlMembershipCondition"
version="1" Url="$AppDirUrl$/*"/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="ASP.Net">
<IMembershipCondition class="UrlMembershipCondition"
version="1" Url="$CodeGen$/*"/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="Nothing">
<IMembershipCondition class="ZoneMembershipCondition"
version="1" Zone="MyComputer"/>
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="FullTrust" Name="Microsoft_Strong_Name"
Description="This code group grants code signed with the Microsoft
strong name full trust. ">
<IMembershipCondition
class="StrongNameMembershipCondition" version="1"
PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293"/
>
</CodeGroup>
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="FullTrust" Name="Ecma_Strong_Name"
Description="This code group grants code signed with the ECMA strong
name full trust. ">
<IMembershipCondition
class="StrongNameMembershipCondition" version="1"
PublicKeyBlob="00000000000000000400000000000000"/>
</CodeGroup>
</CodeGroup>
</CodeGroup>
</PolicyLevel>
</policy>
</security>
</mscorlib>

<!--/medium-trust -->


On Dec 4, 12:45 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>

fire

unread,
Jan 1, 2010, 5:12:05 PM1/1/10
to Castle Project Users
I get the issue off the trunk binaries.
Narrowed down to ModuleScope.
Did a quick test to make sure it was and here is a photo (in the
files section):
http://groups.google.com/group/castle-project-users/web/dynamicproxy2-modulescope-mediumtrust-error.PNG

On Dec 4 2009, 6:49 pm, Gitted <sahmed1...@gmail.com> wrote:
> Thanks, currently I am stuck because ofmediumtrustissues at


> rackspacecloud sites.
>
> Exception Details: System.Security.SecurityException: That assembly
> does not allow partially trusted callers.
>
> Source Error:
>
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of
> the exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
> [SecurityException: That assembly does not allow partially trusted
> callers.]
>    Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
> String strongAssemblyName, String strongModulePath, String
> weakAssemblyName, String weakModulePath) +0
>    Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)
> +35
>    Castle.DynamicProxy.ProxyGenerator..ctor() +38
>    NHibernate.ByteCode.Castle.ProxyFactory..cctor() +49
>
> This is the web.config they gave for testing, although it works
> locally so not sure if this "test" web.config is of any use!
>

> <!--medium-trusttesting -->

> On Dec 4, 12:45 pm, Krzysztof Ko¼mic <krzysztof.koz...@gmail.com>


> wrote:
>
> > no,
>
> > Current NH uses DP 2.1 but will update soon.
>
> > Gitted wrote:
> > > So are you both saying the opposite things here? :)
>

> > > On Dec 4, 12:17 pm, Krzysztof Ko¼mic <krzysztof.koz...@gmail.com>


> > > wrote:
>
> > >> yeah,
>
> > >> provider for Castle will be updated soon.
>
> > >> Jonathon Rossi wrote:
>
> > >>> IIRC NHibernate's current
>

> ...
>
> read more »

Sam Kimmel

unread,
Jan 22, 2010, 2:45:05 AM1/22/10
to Castle Project Users
Same issue here. I thought Medium Trust issues were fixed in 2.2?

On Jan 1, 4:12 pm, fire <dan...@gmail.com> wrote:
> I get the issue off the trunk binaries.
> Narrowed down to ModuleScope.
>  Did a quick test to make sure it was and here is a photo (in the

> files section):http://groups.google.com/group/castle-project-users/web/dynamicproxy2...

> > PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100­010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79­AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4­E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC49­63D261C8A12436518206DC093344D5AD293"/


>
> >               </CodeGroup>
> >               <CodeGroup class="UnionCodeGroup" version="1"
>

> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -

Krzysztof Koźmic (2)

unread,
Jan 22, 2010, 2:51:41 AM1/22/10
to Castle Project Users
Sam,

Yes, they were, but you need the assembly to have the
AllowPartiallyCallersAttribute, which means you will have to build it
yourself, since we do not provide such version for security reasons.

> ...
>
> więcej >>

Sam Kimmel

unread,
Jan 22, 2010, 3:33:47 AM1/22/10
to Castle Project Users
Thanks Krzysztof. I downloaded Nant and haven't had any luck building
from the trunk. I went to the buildscripts folder and ran the
build.cmd as per the instructions. When I ran it I got an error:

=======================
This project is not configured to be built with MSBuild.
Please use the NAnt script in the root folder of this project.
=======================

So then I went back to the root and ran NAnt. Exactly where do I need
to specify to allow partially trusted callers? Also is there a way to
get it to do a release build instead of a debug? Below are the
results of the NAnt process...

But before that, exactly what are the security reasons for not
providing a AllowPartiallyCallers version? If web users have to go
beyond Medium Trust to use Dynamic Proxy aren't they already making
their app less secure?

=======================

NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/Web/CastleDynamicProxy/default.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: build


common.find-svninfo:

[exec] C:\Web\CastleDynamicProxy\buildscripts\common.xml(195,4):
[exec] 'svn' failed to start.
[xmlpeek] Peeking at 'C:\Web\CastleDynamicProxy\_revision.xml' with
XPath expression '/info/entry/@revision'.
[xmlpeek] C:\Web\CastleDynamicProxy\buildscripts\common.xml(206,4):
[xmlpeek] XML file 'C:\Web\CastleDynamicProxy\_revision.xml' does
not exist.
[echo] INFO: Using Subversion revision number: 0

common.build:


common.build.internal:

[nant] C:\Web\CastleDynamicProxy\src\Castle.DynamicProxy
\default.build
Buildfile: file:///C:/Web/CastleDynamicProxy/src/Castle.DynamicProxy/default.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: build


common.find-svninfo:

[exec] C:\Web\CastleDynamicProxy\buildscripts
\common.xml(195,4):
[exec] 'svn' failed to start.
[xmlpeek] Peeking at 'C:\Web\CastleDynamicProxy\src
\Castle.DynamicProxy\_revision.xml' with XPath expression '/info/entry/
@revision'.
[xmlpeek] C:\Web\CastleDynamicProxy\buildscripts
\common.xml(206,4):
[xmlpeek] XML file 'C:\Web\CastleDynamicProxy\src
\Castle.DynamicProxy\_revision.xml' does not exist.
[echo] INFO: Using Subversion revision number: 0

set-framework-configuration:

[script] Scanning assembly "op4sf4wa" for extensions.

set-net-3.5-framework-configuration:


set-project-configuration:


set-debug-project-configuration:


common.init:


init:


common.set-assembly-attribute-values:


common.generate-assemblyinfo:

[attrib] Setting file attributes for 1 files to Normal.

common.copy.project.references:

[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.

common.compile-dll:


build:


BUILD SUCCEEDED - 2 non-fatal error(s), 0 warning(s)

Total time: 1 seconds.

[nant] C:\Web\CastleDynamicProxy\src\Castle.DynamicProxy.Tests
\default.build
Buildfile: file:///C:/Web/CastleDynamicProxy/src/Castle.DynamicProxy.Tests/default.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: test


common.find-svninfo:

[exec] C:\Web\CastleDynamicProxy\buildscripts
\common.xml(195,4):
[exec] 'svn' failed to start.
[xmlpeek] Peeking at 'C:\Web\CastleDynamicProxy\src
\Castle.DynamicProxy.Tests\_revision.xml' with XPath expression '/info/
entry/@revision'.
[xmlpeek] C:\Web\CastleDynamicProxy\buildscripts
\common.xml(206,4):
[xmlpeek] XML file 'C:\Web\CastleDynamicProxy\src
\Castle.DynamicProxy.Tests\_revision.xml' does not exist.
[echo] INFO: Using Subversion revision number: 0

set-framework-configuration:

[script] Scanning assembly "waldny83" for extensions.

set-net-3.5-framework-configuration:


set-project-configuration:


set-debug-project-configuration:


common.init:


common.copy.project.references:

[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.

init:


common.compile-tests:


common.set-assembly-attribute-values:


common.generate-assemblyinfo:

[attrib] Setting file attributes for 1 files to Normal.

common.copy.project.references:

[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.
[copy] Copying 1 file to 'C:\Web\CastleDynamicProxy
\build\net-3.5\debug'.

common.compile-dll:


common.configure-tests:

[attrib] Setting file attributes for 1 files to Normal.
[xmlpoke] No matching nodes were found with XPath
expression '/configuration/appSettings/add[@key='tests.src']/@value'.

common.run-tests:

[echo] Running tests in 'Castle.DynamicProxy2.Tests'

BUILD FAILED - 2 non-fatal error(s), 1 warning(s)

C:\Web\CastleDynamicProxy\buildscripts\common-project.xml
(311,5):
'nunit-console.exe' failed to start.
The system cannot find the file specified

Total time: 1 seconds.


BUILD FAILED - 2 non-fatal error(s), 0 warning(s)

Nested build failed. Refer to build log for exact reason.

Total time: 2.2 seconds.

Krzysztof Koźmic (2)

unread,
Jan 22, 2010, 3:54:18 AM1/22/10
to Castle Project Users
Sam,

sorry for the inconvenience, we are changing our build, moving away
from nant.

try to build with the following command (assuming you have NAnt in
your PATH)

nant -D:assembly.allow-partially-trusted-callers=true clean merge
build

about the reasons for not providing APTCA assemblies OOTB see this
thread:
http://groups.google.com/group/castle-project-devel/browse_thread/thread/33a891ce7da71225/f6bd971e33a54a9c

On 22 Sty, 09:33, Sam Kimmel <sweep...@gmail.com> wrote:
> Thanks Krzysztof. I downloaded Nant and haven't had any luck building
> from the trunk. I went to the buildscripts folder and ran the
> build.cmd as per the instructions. When I ran it I got an error:
>
> =======================
> This project is not configured to be built with MSBuild.
> Please use the NAnt script in the root folder of this project.
> =======================
>
> So then I went back to the root and ran NAnt. Exactly where do I need
> to specify to allow partially trusted callers? Also is there a way to
> get it to do a release build instead of a debug? Below are the
> results of the NAnt process...
>
> But before that, exactly what are the security reasons for not
> providing a AllowPartiallyCallers version? If web users have to go
> beyond Medium Trust to use Dynamic Proxy aren't they already making
> their app less secure?
>
> =======================
>
> NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)

> Copyright (C) 2001-2007 Gerry Shawhttp://nant.sourceforge.net

> ...
>
> więcej >>

Sam Kimmel

unread,
Jan 22, 2010, 2:32:08 PM1/22/10
to castle-pro...@googlegroups.com
Krzysztof,

Thanks again.  What you said makes sense. Unfortunately, I don't think the command is working. Should the final assembly sill end up in debug directory?  I put in the fresh assembly and rebuilt the NHibernate.ByteCode.Castle project and my project but still get the same permission error (below).  Do I need a different version of NAnt? I've tried NAnt 0.85 and 0.86 beta.

In Matijn Boland's blog he talked about adding the APTCA attribute and needing to make a modification to the code so that debug info wasn't emitted for AssemblyBuilder.DefineDynamicModule. The svn trunk already had this modification made (ModuleScope class). So I don't think that is the problem.

Medium Trust seems like a fairly common restraint put on shared hosting customers.  How difficult would it be for the Castle team to set up the build process to output DynamicProxy2.dll and a DynamicProxy2MT.dll (with a disclaimer saying that the 2MT version should only be used when Medium Trust is the only option)?

Is there anyone out there  with a working Medium Trust version of Dynamic Proxy 2.2 that would be willing to share the final assembly?



==========================

[SecurityException: That assembly does not allow partially trusted
callers.]
   Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
INamingScope namingScope, String strongAssemblyName, String
strongModulePath, String weakAssemblyName, String weakModulePath) +0
   Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
String strongAssemblyName, String strongModulePath, String
weakAssemblyName, String weakModulePath) +75
   Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)
+62
   Castle.DynamicProxy.ModuleScope..ctor() +31
   Castle.DynamicProxy.DefaultProxyBuilder..ctor() +44
   Castle.DynamicProxy.ProxyGenerator..ctor() +44
   NHibernate.ByteCode.Castle.ProxyFactory..cctor() +49
=============================



2010/1/22 Krzysztof Koźmic (2) <krzy...@kozmic.pl>

xtoff

unread,
Jan 22, 2010, 3:02:52 PM1/22/10
to Castle Project Users
http://groups.google.com/group/castle-project-users/web/APTCA-DP-UNSUPPORTED%21.zip

On 22 Sty, 20:32, Sam Kimmel <sweep...@gmail.com> wrote:
> Krzysztof,
>
> Thanks again.  What you said makes sense. Unfortunately, I don't think the

> command is working. Should the final assembly sill end up in *debug
> *directory?


> I put in the fresh assembly and rebuilt the NHibernate.ByteCode.Castle
> project and my project but still get the same permission error (below).  Do
> I need a different version of NAnt? I've tried NAnt 0.85 and 0.86 beta.
>
> In Matijn Boland's

> blog<http://blogs.taiga.nl/martijn/2009/06/24/new-adventures-under-medium-...>he

> 2010/1/22 Krzysztof Koźmic (2) <krzysz...@kozmic.pl>


>
> > Sam,
>
> > sorry for the inconvenience, we are changing our build, moving away
> > from nant.
>
> > try to build with the following command (assuming you have NAnt in
> > your PATH)
>
> > nant -D:assembly.allow-partially-trusted-callers=true clean merge
> > build
>
> > about the reasons for not providing APTCA assemblies OOTB see this
> > thread:
>

> >http://groups.google.com/group/castle-project-devel/browse_thread/thr...

> ...
>
> więcej »

Sam Kimmel

unread,
Jan 22, 2010, 6:45:17 PM1/22/10
to Castle Project Users
Thanks xtoff. When I saw the assemblies you posted I realized that
both the Core and the Dynamic Proxy were rebuilt. I was only
rebuilding the Dynamic Proxies.

Just in case anyone else is interested in getting NHibernate + Castle
Dynamic Proxy working in medium trust, this is what you need to do:

1. If you don't have a SVN client, you'll need to download one. I
used SubCommander (http://subcommander.tigris.org/), and while there
seem to be a couple quirky interface bugs, it did allow me to download
the trunks to the directories of my choice.
2. Download Nant (I used 0.86 beta) from http://nant.sourceforge.net/.
To install:
a. Extract it to a directory
b. Create a file called nant.bat with the following contents and
save it in C:\Windows
@echo off
"C:\<Path_To_Nant>\bin\NAnt.exe" %*

3. Download Castle Core from the svn: https://svn.castleproject.org/svn/castle/Core/trunk
a. Edit the file buildscripts\CommonAssemblyInfo.cs and add the
following:
using System.Security;
[assembly: AllowPartiallyTrustedCallers]
(**Note**: I added this because the nant parameter below
didn't seem to do inject it)
b. Open the command prompt and navigate to the root directory,
then run:


nant -D:assembly.allow-partially-trusted-callers=true clean
merge build

4. Download Castle Dynamic Proxies from the svn:
https://svn.castleproject.org/svn/castle/DynamicProxy/trunk
a. Copy the Castle.Core.dll from the build directory in Step 3
into the lib directory of the Dynamic Proxy project
b. Open the command propomt and navigate to the root directory,
then run:


nant -D:assembly.allow-partially-trusted-callers=true clean
merge build

5. Download the NHibernate source from: http://sourceforge.net/projects/nhibernate/files/
a. Open src\NHibernate.Everything.sln in Visual Studio
b. Expand the NHibernate.ByteCode.Castle project
i. Delete the references to Castle.Core and
Castle.DynamicProxy2 and replace them with the assemblies created in
steps 3 & 4
ii. Build NHibernate.ByteCode.Castle

6. Open the projects you are working on that require medium trust
a. Update the references to Castle.Core, Castle.DynamicProxy2,
and NHibernate.ByteCode.Castle in your project
b. Make sure you have the [assembly:
AllowPartiallyTrustedCallers] attribute in the AssemblyInfo.cs file
for each of your own projects
c. When setting up your NHibernate configuration, do this:
/* for whatever reason, the <reflection-optimizer
use="false"/> is being ignored in hibernate.cfg.xml, so we need this
*/
NHibernate.Cfg.Environment.UseReflectionOptimizer = false;
config = new Configuration().Configure();

7. Build your projects and run your web pages in Medium Trust!

On Jan 22, 2:02 pm, xtoff <krzysztof.koz...@gmail.com> wrote:
> http://groups.google.com/group/castle-project-users/web/APTCA-DP-UNSU...

> > > file:///C:/Web/CastleDynamicProxy/src/Castle.DynamicProxy.Tests/default.bui­ld

Krzysztof Koźmic

unread,
Jan 23, 2010, 5:05:35 AM1/23/10
to castle-pro...@googlegroups.com
Sam

could you post that to the wiki:
http://using.castleproject.org/display/CASTLE/Castle+Project

it would be more easily discoverable... google thread will disappear
quickly and we'll have people asking the same question over again.

cheers,

Krzysztof

> steps 3& 4

Reply all
Reply to author
Forward
0 new messages