CustomPaperSource重置并给出nullreferece [英] CustomPaperSource resets and gives a nullreferece

查看:69
本文介绍了CustomPaperSource重置并给出nullreferece的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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链接


http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC& DOCTYPE = KC&安培;外部ID = c2014922&安培; sliceId =安培; dialogID = 7202396&安培; STATEID = 1%200%207200708


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

解决方案

you have to use one of the kinds defined in

System.Drawing.Printing.PaperSourceKind.

if you know the name of the paper source use paperSource prperty

look at the floowing link

http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2014922&sliceId=&dialogID=7202396&stateId=1%200%207200708


这篇关于CustomPaperSource重置并给出nullreferece的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆