SetDataSource()崩溃了 [英] SetDataSource() crashes

查看:107
本文介绍了SetDataSource()崩溃了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欢迎所有Crystal Reports专家。我遇到了一个奇怪的问题。如果你知道如何修复它,请告诉我。

Hello to all Crystal Reports expert. I am running into a strange problem.  Please let me know if you know how to fix it.

我在Visual Studio中有一个报告对象(一个类)的报告。我在运行时传入该对象的ArrayList。那是我得到如下所示的例外情况。这是我使用的代码:

I have a report in Visual Studio that reports off of an object (a class).  I pass in an ArrayList of that object at run time.  That's when I get the exception shown below.  Here's the code I use:

//创建报告实例

MyTestReport report = new MyTestReport ();

MyTestReport report = new MyTestReport ();

列表 < MyObject > entityList = new List < MyObject >();

entityList.Add( new MyObject( arg1,arg2));

entityList.Add(new MyObject(arg1, arg2));

report.SetDataSource(entityList);

CrystalReportViewer reportViewer = new CrystalReportViewer ();

reportViewer.ReportSource = report;

reportViewer.ReportSource = report;

reportViewer.Show();

reportViewer.Show();

这是我得到的例外

---------------------

---------------------

异常被抛出System.RuntimeMethodHandle._InvokeMethodFast(Object target,Object []参数,SignatureStruct&)中的调用目标。

Exception has been thrown by the target of an invocation.

。在System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,Binder binder,Object []参数,CultureInfo文化,布尔skipVisibilityChecks)

System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object []参数,CultureInfo文化)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object [] index,CultureInfo culture)

在System.Reflection.RuntimePropertyInfo.GetValue(Object obj,Object [] index)
在CrystalDecisions CrystalDecisions.CrystalReports.Engine.Table.Enum中的.CrystalReports.Engine.Table.BuildTableFromEnumerable(IEnumerable collection,Type dataClassType,String tableName)
erableToDataSet(IEnumerable collection)
在CrystalDecisions.CrystalReports.Engine.Table.WrapAndCacheDotNetObject(Object val,Type type,IntPtr& pUnkDataSet,IntPtr& pDotNetDelegate)
在CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val,Type type)
在CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val,Type type)
在CrystalDecisions.CrystalReports。 Engine.ReportDocument.SetDataSource(IEnumerable enumerable)

   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at CrystalDecisions.CrystalReports.Engine.Table.BuildTableFromEnumerable(IEnumerable collection, Type dataClassType, String tableName)
   at CrystalDecisions.CrystalReports.Engine.Table.EnumerableToDataSet(IEnumerable collection)
   at CrystalDecisions.CrystalReports.Engine.Table.WrapAndCacheDotNetObject(Object val, Type type, IntPtr& pUnkDataSet, IntPtr& pDotNetDelegate)
   at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(IEnumerable enumerable)

推荐答案

我怀疑海报仍有这个问题,但我要发布一个回复以防万一其他人遇到类似的问题。我最近有完全相同的错误完成上面所描述的,我能够解决它。我有以下提示:

I doubt the poster is still having this problem, but I am going to post a reply just in case someone else encounters a similar problem. I recently had the exact same error doing exactly what has been described above, and I was able to fix it. I have the following tip:

如果任何属性的任何get访问器都可能导致此错误在你的对象上抛出一个错误。我认为(但我不确定)只写属性也会导致此错误。

This error can be caused if any of the get accessors for any of the properties on your object are throwing an error. I think (but I am not sure) that having write only properties can also cause this error was well.


这篇关于SetDataSource()崩溃了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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