【问题标题】:The process cannot access the file error with System.Web.UI.DataVisualization.Charting进程无法使用 System.Web.UI.DataVisualization.Charting 访问文件错误
【发布时间】:2011-10-21 17:43:21
【问题描述】:

我使用 System.Web.DataVisualization 中的图表。

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
...
<asp:Chart ImageType="Png" runat="server" ID="chartStatComp" Palette="BrightPastel"
    ImageLocation="~/CRM/Reports/chartStatComp_#SEQ(100,10)" ImageStorageMode="UseImageLocation"
    Width="620" Height="300">
    <ChartAreas>
        <asp:ChartArea Name="MainChartArea">
        </asp:ChartArea>
    </ChartAreas>
    <Series>
        <asp:Series ChartArea="MainChartArea" ChartType="Pie" XValueType="String" YValueType="Int32"
            CustomProperties="DoughnutRadius=25, PieDrawingStyle=Concave, CollectedLabel=Other, MinimumRelativePieSize=20"
            XValueMember="StateDescription" YValueMembers="CNT" Legend="Legend" IsVisibleInLegend="true"
            IsValueShownAsLabel="true">
        </asp:Series>
    </Series>
    <Legends>
        <asp:Legend LegendStyle="Table" Name="Legend" Alignment="Near"
            TitleAlignment="Near">
            <CellColumns>
                <asp:LegendCellColumn Text="Color" ColumnType="SeriesSymbol" />
                <asp:LegendCellColumn Text="#LEGENDTEXT" ColumnType="Text" Alignment="TopLeft" HeaderText="State" />
                <asp:LegendCellColumn Text="#VAL" ColumnType="Text" Name="Cnt" Alignment="TopLeft"
                    HeaderText="Count" />
                <asp:LegendCellColumn Text="#PERCENT" ColumnType="Text" Name="Percentage" Alignment="TopLeft"
                    HeaderText="%" />
            </CellColumns>
        </asp:Legend>
    </Legends>
</asp:Chart>

它大部分时间都运行良好。但有时用户会遇到异常:

System.IO.IOException: The process cannot access the file '~\Reports\chartStatComp_000001.png' because it is being used by another process.

这种情况非常罕见,但确实如此。 有没有人遇到过类似的问题?

【问题讨论】:

  • 好吧。我刚刚添加了代码,女巫为文件提供了唯一的名称并清理了旧文件。新文件被锁定。

标签: asp.net charts


【解决方案1】:

请提供代码以进行更多分析。

但此时可以假设文件在您尝试写入/读取时必须处于打开状态。它必须在极少数情况下发生,因为文件可能正在处理中并且可能尚未完成其处理。您的代码执行速度足够快,足以陷入这种巧合。

【讨论】:

  • 我提供了代码。好的,如果文件正在处理中,我该如何检查?
猜你喜欢
  • 2015-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多