I think it's because we use a WeakReference<T> that inherits from WeakReference, which in turn, requires has this security attribute: "SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]". I'm going to test on a machine with a medium trust CAS and see if the change fixes anything.
Thanks, Christopher On Tue, Aug 14, 2012 at 8:21 AM, Christopher Currens <currens.ch...@gmail.com> wrote: > It must be something we've missed, as we want to target medium trust > locations in the future. I can't think of anything off the top of my > head that would require medium trust, though, let alone unmanaged > code. I'll dive into this. > > > Thanks, > Christopher > > On Mon, Aug 13, 2012 at 10:01 PM, Simon Svensson <si...@devhost.se> wrote: >> Hi, >> >> I'm having trouble upgrading a web application running under medium trust >> from 2.9.4 to 3.0.3. Code that previously worked now throws a >> SecurityException. >> >> [SecurityException: Request for the permission of type >> 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, >> Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] >> Lucene.Net.Support.WeakKey`1..ctor(T key) +0 >> Lucene.Net.Support.WeakDictionary`2.get_Item(TKey key) +113 >> Lucene.Net.Util.DefaultAttributeFactory.GetClassForInterface() +178 >> Lucene.Net.Util.DefaultAttributeFactory.CreateAttributeInstance() +95 >> Lucene.Net.Util.AttributeSource.AddAttribute() +375 >> Lucene.Net.Analysis.CharTokenizer..ctor(TextReader input) +126 >> Lucene.Net.Analysis.WhitespaceTokenizer..ctor(TextReader in) +37 >> >> >> The DefaultAttributeFactory, via WeakReference, requires >> SecurityPermissionFlag.UnmanagedCode which is not present under medium >> trust. There's an AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY which I could >> to replace the DefaultAttributeFactory, but it's readonly. I'm rewriting my >> code to call the constructor overload (on tokenizers) accepting an >> AttributeFactory, but this means that I cannot use any existing Analyzer >> since they don't provide an extension points to change the AttributeFactory. >> >> Is medium trust [using default classes] dropped in 3.0.3, or is this >> something we've missed? >> >> // Simon