Hi,
we have another issue related to LLBLGen in medium trust and it is related to LLBLGen to Linq. Here is the exception that we get:
System.MethodAccessException was unhandled by user code
Message="System.Runtime.CompilerServices.StrongBox`1..ctor(System.__Canon)"
Source="mscorlib"
StackTrace:
at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Linq.Expressions.ExpressionCompiler.AddGlobal(Type type, Object value)
at System.Linq.Expressions.ExpressionCompiler.GenerateConstant(ILGenerator gen, Type type, Object value, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.GenerateConstant(ILGenerator gen, ConstantExpression c, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.Generate(ILGenerator gen, Expression node, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.GenerateArgs(ILGenerator gen, ParameterInfo[] pis, ReadOnlyCollection`1 args)
at System.Linq.Expressions.ExpressionCompiler.GenerateMethodCall(ILGenerator gen, MethodInfo mi, ReadOnlyCollection`1 args, Type objectType)
at System.Linq.Expressions.ExpressionCompiler.GenerateMethodCall(ILGenerator gen, MethodCallExpression mc, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.Generate(ILGenerator gen, Expression node, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.GenerateConvert(ILGenerator gen, UnaryExpression u)
at System.Linq.Expressions.ExpressionCompiler.Generate(ILGenerator gen, Expression node, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.GenerateConvert(ILGenerator gen, UnaryExpression u)
at System.Linq.Expressions.ExpressionCompiler.Generate(ILGenerator gen, Expression node, StackType ask)
at System.Linq.Expressions.ExpressionCompiler.GenerateLambda(LambdaExpression lambda)
at System.Linq.Expressions.ExpressionCompiler.CompileDynamicLambda(LambdaExpression lambda)
at System.Linq.Expressions.LambdaExpression.Compile()
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.SetupProjectionElementsForExecution(QueryExpression toExecute)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteValueListProjection(QueryExpression toExecute)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at SD.LLBLGen.Pro.LinqSupportClasses.QueryableExtensionMethods.CountColumn[TSource,TColumnType](IQueryable`1 source, Expression`1 selector, Boolean applyDistinct)
at MonoSoftware.MonoX.Repositories.MessageRepository.GetMessages(Guid parentMessageId, Guid userId, Int32 pageIndex, Int32 pageSize, Int32& recordCount) in D:\Projects\MonoX2\Portal\MonoX\Code\Layers\Repositories\MessageRepository.cs:line 222
at MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageDetails.BindData() in D:\Projects\MonoX2\Portal\MonoX\ModuleGallery\SocialNetworking\Messaging\MessageDetails.ascx.cs:line 217
at MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageDetails.Page_Load(Object sender, EventArgs e) in D:\Projects\MonoX2\Portal\MonoX\ModuleGallery\SocialNetworking\Messaging\MessageDetails.ascx.cs:line 174
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at MonoSoftware.MonoX.BasePart.OnLoad(EventArgs e) in D:\Projects\MonoX2\Portal\MonoX\Code\BaseClasses\BasePart.cs:line 1112
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Security.SecurityException
Message="Request failed."
Source="mscorlib"
StackTrace:
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh)
at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh)
at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
at System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext)
at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant)
InnerException:
I have found a few posts related to the exception that we get, and all of them are suggesting the change in the configuration that we can do because Microsoft is moving towards this medium trust configuration:
<IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/>
Which will be required if we want to include our product in Microsoft application gallery.
The code that we are using is when we get the exception is:
using (IDataAccessAdapter dataAdapter = GetAdapter())
{
LinqMetaData metaData = new LinqMetaData(dataAdapter);
var q = (from topics in metaData.SnDiscussionTopic
where topics.SnDiscussionBoardId == boardId
select topics).Count();
return q;
}
I have seen the http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=19640 thread but for us it is unacceptable to move to the 3.x version, we are bound to the 2.6 version.
Is there anything that we can do to fix this issue ?
Our previous topic on medium trust
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=19685
Regards