tags:

views:

213

answers:

2

I want to run Castle.Core under medium trust, and I know how to do it in theory.

  1. Add [AllowPatiallyTrustedCallers] to the Assembly.cs
  2. Disable Trace Logger - (because it uses reflection)

First problem, there is is no Assembly.cs, so apparently you can use nant to build with a command line like:

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

But that returns an error

NAnt 0.84 (Build 0.84.1455.0; net-1.0.win32; release; 26/12/2003)
Copyright (C) 2001-2003 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///D:/Downloads/development - source/Castle Proxy/Core/src/Castl
e.Core/default.build
Target(s) specified: nant

BUILD FAILED

Property 'project::get-name()' has not been set.

Total time: 0.1 seconds.

How do I set this or resolve the issue? The svn for this the Castle.Core is https://svn.castleproject.org/svn/castle/Core/trunk so your welcome to check it out before answering if you want

+1  A: 

I think you're going the wrong way about it - You don't need to add [AllowPatiallyTrustedCallers] to run in medium trust. You only need APTCA if you're going to GAC the assembly, in which case you wouldn't need to remote Trace Logger because GACed assemblies run in full trust and reflection would work.

blowdart
Seems you might be wrong here. I did have to to do the build with the APTCA on it. See Krzysztof's answer.
burnt_hand
That's really weird. APTCA doesn't come into play unless you're talking across trust levels. Even the linked MSDN doc says it's "shared managed libraries".
blowdart
+1  A: 

[UPDATE]

OK, my bad. I'm not an expert in medium trust issues, but the way I understand it, you need APTCA on Castle assemblies after all.

So here's what I did:

I pulled Castle Core from: https://svn.castleproject.org/svn/castle/Core/trunk downloaded latest nightly build of NAnt and built it with nant build -D:assembly.allow-partially-trusted-callers=true

I then downloaded Dynamic Proxy from: https://svn.castleproject.org/svn/castle/DynamicProxy/trunk

copied the Core assembly I built in previous step to lib/net-35 and then built DP with the same Nant command.

I then created an ASP.NET website with trust level set to Medium and generated a couple of proxies in it, and it worked.

If for some reason that does not work for you, or you have any other issues/suggestions let me know.

Krzysztof Koźmic
Thanks for the info and the link. Will buy you a beer when I get to Krakow. I guess its DynamicProxy2 causing the issue then. I just did a test with an empty web project where I tried to build a ProxyGenerator in the codebehind with <trust level="Medium"/>. It seems to be the ModuleScope causing the issue. Do you know of any issues with that?
burnt_hand
I have moved this over to the Castle Users Group. Uploaded an image with the error
burnt_hand
Magic! Just built, compiled and ran. :) I'm very very happy right now!
burnt_hand
glad to help :)
Krzysztof Koźmic