我试图搜索此异常,但我找不到任何解决方案
我使用下面的代码来调用.NET应用程序:
Assembly assem = Assembly.Load(Data);
MethodInfo method = assem.EntryPoint;
var o = Activator.CreateInstance(method.DeclaringType);
method.Invoke(o, null);
Run Code Online (Sandbox Code Playgroud)
将被调用的应用程序具有一个Form并位于应用程序的EntryPoint中:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); //Exception
Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud)
SetCompatibleTextRenderingDefault必须IWin32Window在应用程序中创建第一个对象之前调用.
编辑:
Assembly a = Assembly.Load(Data);
MethodInfo method = a.GetType().GetMethod("Start");
var o = Activator.CreateInstance(method.DeclaringType);
method.Invoke(o, null);
Run Code Online (Sandbox Code Playgroud) 我正在使用 Crystal 报表查看器:
Printer.Lavage.Report.LavageReport Report = new Printer.Lavage.Report.LavageReport();
Report.SetDataSource(order);
Printer.Lavage.View.LavageReport_FRM LavageReporter = new Printer.Lavage.View.LavageReport_FRM();
LavageReporter.crystalReportViewer1.ReportSource = Report;
LavageReporter.Show();
Run Code Online (Sandbox Code Playgroud)
但我得到了例外:
The data source object is invalid.
Run Code Online (Sandbox Code Playgroud)