问题描述
Hi
打印CrystalReport时,CustomPaperSource有时会重置为null。
只有在RawKind设置为giro(包含
"261",我的打印机上的纸张源代码)之后才会出现问题,而且只有一次在。
示例代码:
System.Drawing.Printing.PaperSource source
= new System.Drawing.Printing.PaperSource();
int farge = 259,giro = 260,vanlig = 261;
rdReport.PrintOptions.CustomPaperSource = source;
if(printoptions ==" farge")
rdReport.PrintOptions.CustomPaperSource.RawKind = farge;
else if(printoptions ==" giro")
rdReport.PrintOptions.CustomPaperSource.RawKind = giro;
rdReport.PrintOptions.CustomPaperSource.RawKind = vanlig;
if(null == rdReport.PrintOptions.CustomPaperSource)
Console.WriteLine(" Err!");
frmMain.WriteLog(" now printing" + sFilename);
frmMain .WriteLog(" printoptions设置为" +
rdReport.PrintOptions.CustomPaperSource.RawKind.ToString());
在最后一行我_sometimes_得到一个NullReferenceException。我告诉垃圾收集不要碰到物体。没有帮助。
最后一个"if"不会触发。所以看起来像CustomPaperSource被重置
你必须使用
System.Drawing.Printing 。 PaperSourceKind。
如果您知道纸张来源的名称,请使用paperSource prperty
查看floowing链接
Hi
When printing a CrystalReport CustomPaperSource is sometimes reset to null.
the problem only occures after RawKind has been set to giro (which contains
"261", the code for a paper source on my printer), and only once in a
while.
Sample code:
System.Drawing.Printing.PaperSource source
= new System.Drawing.Printing.PaperSource();
int farge = 259, giro = 260, vanlig = 261;
rdReport.PrintOptions.CustomPaperSource = source;
if (printoptions == "farge")
rdReport.PrintOptions.CustomPaperSource.RawKind = farge;
else if (printoptions == "giro")
rdReport.PrintOptions.CustomPaperSource.RawKind = giro;
else
rdReport.PrintOptions.CustomPaperSource.RawKind = vanlig;
if (null == rdReport.PrintOptions.CustomPaperSource)
Console.WriteLine("Err!");
frmMain.WriteLog("now printing " + sFilename);
frmMain.WriteLog("printoptions set to " +
rdReport.PrintOptions.CustomPaperSource.RawKind.ToString());
at the last line i _sometimes_ get a NullReferenceException. i've told
garbage collection not to touch the object. didn't help.
the last "if" does not trigger. so it seems like CustomPaperSource is reset
when read.
-L
这篇关于CustomPaperSource重置并给出nullreferece的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!