SubSonic Forums
All Your Database Are Belong To Us

help: cannot run on medium trust web server at godaddy

Latest post 03-26-2008 6:31 PM by Eric Kemp. 24 replies.
  • 06-23-2007 11:41 AM

    • zhaff
    • Top 500 Contributor
    • Joined on 06-23-2007
    • Posts 7

    help: cannot run on medium trust web server at godaddy

    Hi,
    I cant run subsonic 2.0.2 on my webserver hosted at godaddy url: http://oims.shockinglabs.com
    I already generated all subsonic DAL class but its seem not working. Anyone please help.

    Below are the error message:

    Server Error in '/oims' Application.

    Required permissions cannot be acquired.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

    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:

    [PolicyException: Required permissions cannot be acquired.]
       System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2738021
       System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57
    
    [FileLoadException: Could not load file or assembly 'SubSonic, Version=2.0.2.0, Culture=neutral, PublicKeyToken=eadb47849839a332' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
       System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
       System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
       System.Reflection.Assembly.Load(String assemblyString) +25
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32
    
    [ConfigurationErrorsException: Could not load file or assembly 'SubSonic, Version=2.0.2.0, Culture=neutral, PublicKeyToken=eadb47849839a332' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +596
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +3487289
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +46
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +177
       System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +180
       System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +347
       System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
       System.Web.Compilation.BuildManager.CompileCodeDirectories() +525
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +448
    
    [HttpException (0x80004005): Could not load file or assembly 'SubSonic, Version=2.0.2.0, Culture=neutral, PublicKeyToken=eadb47849839a332' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +57
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +612
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +456
    
    [HttpException (0x80004005): Could not load file or assembly 'SubSonic, Version=2.0.2.0, Culture=neutral, PublicKeyToken=eadb47849839a332' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3434991
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +252
    

  • 06-23-2007 12:01 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    At this time, SubSonic does not run in medium trust.

    However, we have not recently reviewed what changes and functionality restrictions might be employed to allow such a scenario. I will take a look and see what the possibilities might be for such.

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-23-2007 12:33 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    Could you try the following and let me know how things go?

    1. Open up the source code and locate the AssemblyInfo.cs file Properties directory under the SubSonic project
    2. Replace the following value:

      [assembly: PermissionSet(SecurityAction.RequestMinimum, Unrestricted = true)]

      with

      [assembly: PermissionSet(SecurityAction.RequestMinimum, Unrestricted = false)]

    3. Recompile the SubSonic project, then update the reference in your web project (if necessary) and recompile.

     

    This may help to resolve the issue, or at the very least get beyond this specific problem.

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-23-2007 1:16 PM In reply to

    • zhaff
    • Top 500 Contributor
    • Joined on 06-23-2007
    • Posts 7

    Re: help: cannot run on medium trust web server at godaddy

    Hi Eric,
    Thank you for your prompt reply. I had gone thru the steps and it resolved the issue. I uploaded to the new subfolder http://officeintranet.shockinglabs.com
    Mean while new error occured as I try to add new user record as per below. Appreciate your help. Thank you.

    Server Error in '/officeintranet' Application.

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error:

    Line 58:         user.Email = Email.Text;
    Line 59:         user.AccountStatus = Convert.ToInt16(AccountStatus.SelectedValue);
    Line 60:         user.Save(Convert.ToString(Session["Fullname"]));
    Line 61: 
    Line 62:         //Redirect to user list

    Source File: d:\hosting\slabs\officeintranet\Modules\User\UserForm.aspx.cs    Line: 60

    Stack Trace:

    [SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       SubSonic.Utilities.Utility.WriteTrace(String message) +0
       SubSonic.AbstractRecord`1.ValidateColumnSettings() +88
       SubSonic.ActiveRecord`1.Validate() +10
       SubSonic.ActiveRecord`1.Save(String userName) +42
       Modules_User_UserForm.btnAdd_Click(Object sender, EventArgs e) in d:\hosting\slabs\officeintranet\Modules\User\UserForm.aspx.cs:60
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
       System.Web.UI.Page.ProcessRequest() +86
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.modules_user_userform_aspx.ProcessRequest(HttpContext context) in App_Web__jgoar7y.0.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

  • 06-23-2007 1:24 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    I think we're just going to have to go through these one at a time, unfortunately, and I'm not sure if there will be simple solutions to all of them, but we'll try...

    Would it be possible for you to try this again using a debug compile of the SubSonic.dll? I'd like to get a more detail call stack and error location...

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-23-2007 1:59 PM In reply to

    • zhaff
    • Top 500 Contributor
    • Joined on 06-23-2007
    • Posts 7

    Re: help: cannot run on medium trust web server at godaddy

    here you go. running with subsonic debuged version:

      

    Server Error in '/officeintranet' Application.

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error:

    Line 58:         user.Email = Email.Text;
    Line 59:         user.AccountStatus = Convert.ToInt16(AccountStatus.SelectedValue);
    Line 60:         user.Save(Convert.ToString(Session["Fullname"]));
    Line 61: 
    Line 62:         //Redirect to user list

    Source File: d:\hosting\slabs\officeintranet\Modules\User\UserForm.aspx.cs    Line: 60

    Stack Trace:

    [SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       SubSonic.Utilities.Utility.WriteTrace(String message) +0
       SubSonic.AbstractRecord`1.ValidateColumnSettings() +202
       SubSonic.ActiveRecord`1.Validate() +29
       SubSonic.ActiveRecord`1.Save(String userName) +92
       Modules_User_UserForm.btnAdd_Click(Object sender, EventArgs e) in d:\hosting\slabs\officeintranet\Modules\User\UserForm.aspx.cs:60
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
       System.Web.UI.Page.ProcessRequest() +86
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.modules_user_userform_aspx.ProcessRequest(HttpContext context) in App_Web_j1prcmgp.2.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

  • 06-23-2007 2:09 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    Hmm... I expected to see line numbers rather than offsets... Are you sure it's using the debug version of the assembly?

    In any event, the next thing we should try is to comment out the entire contents of Utility.WriteTrace() in the event that the current environment produces problems in this area.
     

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-23-2007 2:30 PM In reply to

    • sde
    • Top 150 Contributor
    • Joined on 05-12-2007
    • Posts 17

    Re: help: cannot run on medium trust web server at godaddy

     I`m pretty sure , that i succesfully run 2.0 classes on medium trust( with generated class of course, not with buildprovider).

  • 06-23-2007 2:45 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    It's definitely possible, but with so much change in code base, there may be a number of places where a new issue was introduced... However, if we've gotten as far as you have that's pretty good news, and we'll hopefully get to the bottom of it...

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-23-2007 2:59 PM In reply to

    • sde
    • Top 150 Contributor
    • Joined on 05-12-2007
    • Posts 17

    Re: help: cannot run on medium trust web server at godaddy

     Hope it helps.I think that support for medium trust is very important, especially as most of hosting companies restrict that in their enviroments.

    I think that as ORM Subsonic does nothing, that could require full trust. Is the WriteTrace writing to system log?
     

  • 06-23-2007 3:25 PM In reply to

    Re: help: cannot run on medium trust web server at godaddy

    WriteTrace writes to the current TraceContext, if applicable, for web applications, or to the current debug listeners for other apps. These suggest elevated access requirements, and since they are called across the application, I thought it would be good factor to attempt eliminate first. Let me know if you have any success if this the contents are commented out.

    I agree on the trust issues, at least for non build provider models... There are certain places where this is difficult, but if possible we'd love address any we can.
     

    Found a bug? Help us fix it by submitting a Work Item!

  • 06-24-2007 4:15 AM In reply to

    • zhaff
    • Top 500 Contributor
    • Joined on 06-23-2007
    • Posts 7

    Re: help: cannot run on medium trust web server at godaddy

    Eric, the web application successfully run after comment out the whole WriteTrace content. Soo far no error encountered. Thank you.

  • 07-12-2007 3:20 PM In reply to

    • nlb6665
    • Top 500 Contributor
    • Joined on 07-12-2007
    • Kansas City
    • Posts 5

    Re: help: cannot run on medium trust

    Hey guys, I was just testing this out. I'm in a dev environment where I'm manually defining medium trust in the web.config. 

    The WriteTrace comment works for me as far as using the Save() function on the generated DAL object, but I'm having a problem with binding a collection to a data grid. The data pulls out fine using "ObjectCollection().Load()"  I can step the code and set the DataSource on the grid, but during DataBind() I get: Attempt to access the method failed. 

    This occurs in AbstractList.cs, line 309 and reads:
    HiddenForDataBindingAttribute hiddenAttribute =(HiddenForDataBindingAttribute)property.Attributes[typeof(HiddenForDataBindingAttribute)]; 

     //I'm guessing it has to do with the use of typeof() here. 

    It's contained in the function: private static PropertyDescriptorCollection GetPropertyDescriptors(Type typeOfObject);

    Have you all seen anything like this?

    Thanks, 

    -Nathan
     

  • 07-12-2007 4:52 PM In reply to

    Re: help: cannot run on medium trust

    There's a good possibility that you're the first to try direct databinding in a medium trust scenario. As you noticed, the HiddenForDatabinding does a lot of Type kung fu, so it's probably a good candidate for these type of medium trust problems...

    Your best bet right now may be to just remove [HiddenForDataBinding(true)] attributes from any of the properties and recompile. If you're not using AutoGenerateColumns, these descriptors really aren't necessary, and if you are, you could always hide them after the fact.

    Creating a "veneer" for ActiveRecord is one of our future development tasks, which will address this issue in cleaner, trust-safe method. We'd like to make SubSonic medium trust friendly, so please keep us updated on your results and post any bugs as Work Items on CodePlex...

    Found a bug? Help us fix it by submitting a Work Item!

  • 07-12-2007 5:28 PM In reply to

    • nlb6665
    • Top 500 Contributor
    • Joined on 07-12-2007
    • Kansas City
    • Posts 5

    Re: help: cannot run on medium trust

    Gotcha! Thanks!  Yeah I already checked some of that out. I'm testing it now. I've pretty much decided that I want to go with a full trust applications due to some of the other components, but I would like figure out a way to make the medium trust scenario work for small applications that can be hosted on shared providers.  

    Thanks for the quick response!
     

Page 1 of 2 (25 items) 1 2 Next > | RSS