装配createinstance和crystal report的问题

时间:2012-08-15 00:26:18

标签: c# .net crystal-reports crystal-reports-2008 crystal-reports-xi

我加载了一个程序集

private System.Reflection.Assembly;
object myData;

myAssembly = System.Reflection.Assembly.LoadFile("C:\\CrystalDecisions.CrystalReports.Engine.dll");

然后我创建一个实例。

myData=myAssembly.CreateInstance("CrystalDecisions.CrystalReports.Engine.ReportDocument", true);

这个myData总是返回null,为什么它返回null,因为myAssembly有汇编信息及其公钥令牌?

1 个答案:

答案 0 :(得分:0)

尝试类似下面的内容。

// dynamically load assembly from file Test.dll
Assembly myData = Assembly.LoadFile(@"C:\CrystalDecisions.CrystalReports.Engine.dll");

// get type of class Calculator from just loaded assembly
Type myData = myData.GetType("CrystalDecisions.CrystalReports")

// create instance of class Calculator
object myDataInstance = Activator.CreateInstance(myData);

Reflection Examples C#