SecurityException

Jun 10, 2009 at 8:12 PM

Hi,

I´m facing problems to use ChartPart. I´m able to add a chartpart or locked chart part as a web part in my site, but it is presenting an exception instead of a chart.

After installation I received an exception asking for c:\TempImageFiles. I created this path in server to avoid the error, but maybe there is a better solution.

Now, I´m receiving that exception about Security (see it below) in the webpart content instead of a chart image:

An exception occurred:System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.Inspect() at System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.ParseParams(String parameters) at System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings..ctor(String parameters) at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.InitializeParameters() at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInitialized(Boolean hardCheck) at System.Web.UI.DataVisualization.Charting.Chart.GetImageStorageMode() at System.Web.UI.DataVisualization.Charting.Chart.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at ChartPart.ChartPartWebPart.Render(HtmlTextWriter writer) The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.FileIOPermission The Zone of the assembly that failed was: MyComputer
Related to web.config, which is the file should I check?
I found several web.config files, and notice that:
a) C:\Inetpub\wwwroot\wss\VirtualDirectories\34309\web.config
    Have this line:
          <SafeControl Assembly="ChartPart, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b674fbef227b83bb" Namespace="ChartPart" TypeName="*" Safe="True" />
          ....
    <securityPolicy>
      <trustLevel name="WSS_Medium" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_mediumtrust.config" />
      <trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_minimaltrust.config" />
      <trustLevel name="WSS_Custom" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_custom_wss_minimaltrust.config" />
    </securityPolicy>
b) C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG\web.config
    In this file there isn´t any reference to the ChartPart, then I added the same line as above:
<SafeControl Assembly="ChartPart, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b674fbef227b83bb" Namespace="ChartPart" TypeName="*" Safe="True" />
   And have this definition also:
        <securityPolicy>
            <trustLevel name="WSS_Medium" policyFile=""/>
            <trustLevel name="WSS_Minimal" policyFile=""/>
        </securityPolicy>
Please, someone have an idea about what can I do to try to solve this security problem? What should I change in the web.config or other settings?
Thank you in advance,
Fernanda
Coordinator
Jun 10, 2009 at 9:32 PM

Hi,

first of all each web application in Sharepoint (incl Central Admin) has it's own web.config, hence the reason for multiple web.configs.

How did you install ChartPart?
Did you install the Microsoft Chart Controls and activate the MSChartControls solution on your web application?
Can you find any <appSettings> element with reference to the chart in the web.config file?

/WW

Jun 16, 2009 at 2:26 PM

Hi wictor,

I installed following the pdf file. I installed the MS Chart Controls and activated it.

See the C:\Inetpub\wwwroot\wss\VirtualDirectories\34309\web.config content:

  <appSettings>
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <add key="ChartImageHandler" value="storage=memory;timeout=20;" />
  </appSettings>

Is it correct?

Fernanda

 

Coordinator
Jun 16, 2009 at 4:41 PM

Hi,

it looks correct. Is your site running on port 34309?

/WW

Jun 16, 2009 at 8:02 PM

Yes, is it a problem?

Coordinator
Jun 16, 2009 at 8:30 PM

Nope, was just checking that you were looking in the correct web.config. I'll look into it further, have not seen it before, probably some CAS permissions. You could temporary put the chartpart dll into the gac and remove it from the bin to try it out.

/WW

Jun 16, 2009 at 8:59 PM

Hi Wictor,

Could you explain in details how to do this? How to deploy a dll directly - maybe if you send some link / tutorial with instructions...

Unfortunatelly I´m not .NET or Sharepoint developer. I´m Java developer and sharepoint "advanced user".

Thank you,

Fernanda