本文介绍了该进程无法通过System.Web.UI.DataVisualization.Charting访问文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I use charts from 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>

它在大多数时间都可以正常工作。但有时用户会收到异常:

It works well most of the time. But sometimes users gets the exception:

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

它发生的很少,但它是。
任何人都遇到类似的问题吗?

Its happens very rare but it does.Does anyone faced with similar problem?

推荐答案

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

Please provide the code for more analysis .

但在这一点上,可以假定在尝试写入/读取时,文件必须处于打开状态。它必须在极少数情况下发生,因为文件可能正在进行中,并且可能尚未完成其进程。你的代码执行速度足够快,可以达到这种类型的巧合。

But at this point it can be assumed that the file must be in open state at the time you try to write/read. It must be happening in rare cases as the file might be in process and may have not finished its process. Your code execution was fast enough to get into such type of coincidence.

这篇关于该进程无法通过System.Web.UI.DataVisualization.Charting访问文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 21:09