2009-08-14 10 views
2

Ich verwende den Logging Application Block in meiner ASP.NET-Anwendung und möchte die Anwendung in ein Sharepoint WebPart konvertieren.Logging Application Block

Alles in Ordnung, so lange funktioniert, wie ich ändern:

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

to 

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

Wenn nicht ich eine Ausnahme in den Protokollen erhalten:

Failed to add webpart *************255Fcatalogs%252Fwp%252FSearchWebPart%252Ewebpart;SearchWebPart. Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource' threw an exception. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neut...  
...ral, PublicKeyToken=b77a5c561934e089' failed.  at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)  at System.Security.CodeAccessPermission.Demand()  at System.AppDomainSetup.VerifyDir(String dir, Boolean normalize)  at System.AppDomainSetup.get_ConfigurationFile()  at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSourceImplementation..ctor(Boolean refresh)  at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource..cctor() The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.FileIOPermission The first permission that failed was: <IPermission class="System.Security.Permissions.FileIOPermi... 
...ssion, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="D:\Inetpub\wwwroot\wss\VirtualDirectories\8686\web.config"/> The demand was for: <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="D:\Inetpub\wwwroot\wss\VirtualDirectories\8686\web.config"/> The granted set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/> <IPermission class="System.Security.Permissions.StrongNameIdentityPermis... 
...sion, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100257FAE170ABB2AB4A8EF914DFEA757F7DB8C221F01850FC8753A4C6585C0B07749DA33DF4D64A721A070E7CDCDEFC8C786E3626418389BCF461E4300E6F4C477BE5CE64AD12C29D517208D6BA627D9F73A9066B7638BE1FEE3EABE6C3E537B546CB3B5DE5E436F95278BB1E9DBDE85C2A6B624010A8073841D467CC7A0A0C6C8" Name="Microsoft.Practices.EnterpriseLibrary.Common" AssemblyVersion="3.1.0.0"/> <IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Url="file:///D:/Inetpub/wwwroot/wss/VirtualDirectories/8686/bin/Microsoft.Practices.EnterpriseLibrary.Common.DLL"/> <IPe... 
...rmission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Zone="MyComputer"/> <IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Minimal"/> <IPermission class="Microsoft.SharePoint.Security.WebPartPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" Connections="True"/> </PermissionSet> The assembly or AppDomain that failed was: Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=a646907c4a695009 The Zone of the assembly that failed was: MyComputer The Url of the assem... 
...bly that failed was: file:///D:/Inetpub/wwwroot/wss/VirtualDirectories/8686/bin/Microsoft.Practices.EnterpriseLibrary.Common.DLL  --- End of inner exception stack trace ---  at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource..ctor()  at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceFactory.Create()  at Microsoft.Practices.EnterpriseLibrary.Logging.Logger..cctor()  --- End of inner exception stack trace ---  at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(LogEntry log)  at com.okana.sharepoint.SearchWebPart.OnLoad(EventArgs e)  at System.Web.UI.Control.LoadRecursive()  at System.Web.UI.Control.AddedControl(Control control, Int32 index)  at System.Web.UI.ControlCollection.Add(Con... 
...trol child)  at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart)  at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPart(WebPart webPart)  at System.Web.UI.WebControls.WebParts.WebPartManager.AddWebPart(WebPart webPart)  at System.Web.UI.WebControls.WebParts.WebPartManagerInternals.AddWebPart(WebPart webPart)  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartWithRetry(WebPart webPart)  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddDynamicWebPart(WebPart webPart)  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.LoadWebPart(WebPart aspWebPart, String zoneId, Int32 zoneIndex, Boolean isClosed)  at Microsoft.SharePoint.WebPartPages.... 
...SPWebPartManager.AddWebPartInternalShared(WebPart webPart)  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)  --- End of inner exception stack trace ---  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset)  at Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) 

Meine Log-Konfiguration ist das:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"> 
    <listeners> 
     <add fileName="XAE.log" rollSizeKB="0" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Overwrite" rollInterval="Day" formatter="Text Formatter" header="" footer="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral" name="Rolling Flat File Trace Listener" /> 
     <add fileName="IDOL.log" rollSizeKB="0" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Overwrite" rollInterval="Day" formatter="Text Formatter" header="" footer="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral" name="IDOL Rolling Flat File Trace Listener" /> 
    </listeners> 
    <formatters> 
     <add template="{timestamp(local)} : {category} : {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral" name="Text Formatter" /> 
    </formatters> 
    <categorySources> 
     <!-- 
     For any log entries that you wish to suppress set "All" to "Off" 
     --> 
     <add switchValue="All" name="Communication"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
     <add switchValue="All" name="Debug"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
     <add switchValue="All" name="Exception"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
     <add switchValue="All" name="General"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
     <add switchValue="All" name="Warning"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
     <add switchValue="All" name="IDOL"> 
     <listeners> 
      <add name="IDOL Rolling Flat File Trace Listener" /> 
     </listeners> 
     </add> 
    </categorySources> 
    <specialSources> 
     <allEvents switchValue="All" name="All Events" /> 
     <notProcessed switchValue="All" name="Unprocessed Category" /> 
     <errors switchValue="All" name="Logging Errors &amp; Warnings"> 
     <listeners> 
      <add name="Rolling Flat File Trace Listener" /> 
     </listeners> 
     </errors> 
    </specialSources> 
    </loggingConfiguration> 

Offensichtlich ist dies, weil es versucht, die Protokolldateien zu erstellen, und WSS_Minimal lässt dies nicht zu. Gibt es eine einfache Möglichkeit, die Protokollierung für jetzt zu deaktivieren? Das Entfernen der Protokollierung ist problematisch, da sie in den zugrunde liegenden Bibliotheken verwendet wird.

Ich habe versucht Einstellung all switchValue = „All“ auf „Aus“, aber es wirft immer noch die Ausnahme, obwohl nichts

protokolliert werden soll

Antwort

4

Wenn Sie minimal Vertrauen verwenden mögen, haben Sie eine Codezugriffssicherheit konfigurieren Politik. Überprüfen Sie den folgenden Post, den ich unten geschrieben habe, der die Sicherheitskonfiguration beschreibt, die für die Verwendung der Enterprise Library-Protokollierung erforderlich ist.

Enterprise Library in SharePoint

+0

OMG :) , die Spaß haben muss ich bereits habe gesetzt AllowPartiallyTrustedCallers zu erarbeiten, aber wusste nicht, dass ich die anderen Dinge zu tun hatte. –