Pavel Novotný

.NET Framework, SharePoint, Dynamics CRM, RC Helicopters, Honda VFR CrossRunner

Zobrazení call stack při chybě

Sharepoint standardně při vzniku exception zobrazuje pouze její message, nikoliv i kompletní call stack, pro zobrazení všech detailů je potřeba modifikovat web.config následovně:

 

<customErrors mode="Off" />

<compilation debug="true">

 a ještě:

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

nebo ještě lepší způsob je mofikace systémovými prostředky Sharepointu, tedy prostředníctvím objektu SPWebConfigModification:

SPWebApplication webApp = siteCollection.WebApplication;
SPWebConfigModification callStackModification = 
     new SPWebConfigModification("CallStack", "configuration/SharePoint/SafeMode");
callStackModification.Value = "true";
callStackModification.Owner = typeof(Program).FullName;
callStackModification.Sequence = 0;
callStackModification.Type = 
     SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
SPWebConfigModification customErrorsModification = 
     new SPWebConfigModification("mode", "configuration/system.web/customErrors");
customErrorsModification.Value = "Off";
customErrorsModification.Owner = typeof(Program).FullName;
customErrorsModification.Sequence = 1;
customErrorsModification.Type = 
     SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
SPWebConfigModification debugModification = 
     new SPWebConfigModification("debug", "configuration/system.web/compilation");
debugModification.Value = "true";
debugModification.Owner = typeof(Program).FullName;
debugModification.Sequence = 2;
debugModification.Type = 
     SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
webApp.WebConfigModifications.Add(callStackModification);
webApp.WebConfigModifications.Add(customErrorsModification);
webApp.WebConfigModifications.Add(debugModification);
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
webApp.Update();

Přidat komentář

Loading