hzt0099 发表于 2018-3-11 15:32:33

ActiveReports报错“System.AccessViolationException”

Exception details:
System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
   在 System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
   在 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   在 System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   在 System.Type.GetType(String typeName)
   在 System.Drawing.Printing.PrintDocument.get_PrintController()
   在 GrapeCity.ActiveReports.Extensibility.Printing.Printer.set_PrintController(PrintController value)
   在 GrapeCity.ActiveReports.Extensibility.Printing.Printer.get_PrintController()
   在 GrapeCity.ActiveReports.Viewer.Win.Printing.PrintImpl.Print(#q0B documentPrintAdapter, Boolean showPrintDialog, Boolean showPrintProgressDialog, Boolean usePrintingThread, Action`1 action)
   在 GrapeCity.ActiveReports.Viewer.Win.Printing.PrintImpl.Print(DocumentModel documentModel, ReportModelBase reportModel, IApplicationContext context, Boolean showPrintDialog, Boolean showPrintProgressDialog, Boolean usePrintingThread)
   在 GrapeCity.ActiveReports.Viewer.Win.WindowsPrintService.Print(DocumentModel documentModel, ReportModelBase reportModel, IApplicationContext context, Boolean showPrintDialog, Boolean showPrintProgressDialog, Boolean usePrintingThread)
   在 GrapeCity.Viewer.Common.ViewModel.ToolbarViewModel.<>c__DisplayClass3e.#9kz()

---打印的时候隔三差五的就报这个错,有时候直接导致程序闪退,请帮忙看看是我程序问题还是ActiveReports的bug。我用的是activeReports 8
谢谢。

KearneyKang 发表于 2018-3-11 16:04:32

本帖最后由 KearneyKang 于 2018-3-12 09:32 编辑

将dll里函数需要返回的局部变量声明为static,然后再重新调试运行看看

hzt0099 发表于 2018-3-12 17:28:29

LZ您好
Dim Type As TypeType = System.Reflection.Assembly.GetExecutingAssembly().GetType(strContactClass, False)
Dim ClassObj As Object = Activator.CreateInstance(Type, COMPANY_NO, DEFAULT_CONTACT_ID, DEFAULT_CENTER_NO, DOC_NO, LIST_BY, ReportPara)
ClassObj.Run()
ReportViewer.Document = ClassObj.Document
我不明白您说的将dll里面需要返回的函数声明为static是啥意思?在打印的时候我先反射加载画好的报表显示预览,然后点击viewer控件上的打印按钮打印,这个逻辑有问题吗?

KearneyKang 发表于 2018-3-12 18:10:47

您好!就是把左右的引用设置为复制到本地。
如下截图:

页: [1]
查看完整版本: ActiveReports报错“System.AccessViolationException”