locked
ASP.NET web app permission issue when calling methods created in a class library project RRS feed

  • Question

  • We have created an ASP.NET (VS 2008) application that we deployed on the _LAYOUT folder. Everything works fine, application can access the SharePoint Object Model and can create new sites, manipulate the Document library etc.
    We then created a class library project and moved most of the code to there for security reasons. Our ASP.NET app now calls the methods residing in the class library (a dll). But during this call, we get the following error:

    ////Error
    Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.
    //////

    Is there any way we can get rid of this error without changing the security settings on production. Our client is not willing to lower the security. Keep in mind the same code works fine if we don’t move it to a class library.
    Thanks……….

    Monday, November 22, 2010 5:45 PM

Answers

  • Hi namwam,

    I think, this is trust level problem with your site. Follow the below steps:

    1. Open your site web.config file. (c:\Inetpub\wwwroot\wss\VirtualDirectories\Port No.)

    2. Make below changes

    <trust level="WSS_Minimal" originUrl="" />

    to

    <trust level="WSS_Medium" originUrl="" />


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    • Proposed as answer by KeFang Chen Tuesday, November 23, 2010 7:10 AM
    • Marked as answer by Mike Walsh FIN Tuesday, November 23, 2010 7:47 AM
    Tuesday, November 23, 2010 4:54 AM

All replies

  • From reading your description, I think its related to adding your new assembly as safe control in the Web.config file for it to be used.

    For example (Under Configuration -> SharePoint):

    <SafeControl Assembly="DemosAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fe89cbb83deb6100" Namespace="DemoAssembly" TypeName="*" Safe="True" />
    


    Dennis Alzoubi
    Monday, November 22, 2010 10:17 PM
  • Hi namwam,

    I think, this is trust level problem with your site. Follow the below steps:

    1. Open your site web.config file. (c:\Inetpub\wwwroot\wss\VirtualDirectories\Port No.)

    2. Make below changes

    <trust level="WSS_Minimal" originUrl="" />

    to

    <trust level="WSS_Medium" originUrl="" />


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    • Proposed as answer by KeFang Chen Tuesday, November 23, 2010 7:10 AM
    • Marked as answer by Mike Walsh FIN Tuesday, November 23, 2010 7:47 AM
    Tuesday, November 23, 2010 4:54 AM
  • You can see the following document.

    http://msdn.microsoft.com/en-us/library/dd583158%28office.11%29.aspx


    Microsoft Online Community Support
    Tuesday, November 23, 2010 7:21 AM
  • Dennis,

    Does this change have to be made to the web.config file of only my web app or to other web.config files on the SharePoint server, as well?

    Thanks.......

    Tuesday, November 23, 2010 11:09 PM