动态DLL有时会导致异常

时间:2016-01-21 13:35:34

标签: c# wpf exception dynamic dll

我在我的wpf应用程序中使用动态dll,我可以加载一个dll就好了,我可以设置事件或输入一个简单的函数并从中返回,我只有一个函数有时会抛出我: “绑定动态操作时出现意外异常”异常。

这种情况并非一直发生,通常是在dll之间切换之后。 我找到的唯一解决方法是创建一个新的类库,然后它可以正常工作,直到下一次......

加载dll:

        Assembly asm = Assembly.LoadFile( unitDllPath );
        Type typ = asm.GetType( Globals.UnitUnderTestComboBox + ".Class1", true, true );             
        unitDll = Activator.CreateInstance( typ );

设置事件并输入dll以检索值:

  unitDll.TerminateDll += new EventHandler( eventTerminateDll );

  unitSerial = unitDll.GetSerialSCPICommand();

“有问题”的功能

 calibrationResult = unitDll.Execute( ref Globals.MessageInput, ref Globals.ImageInput, mbUnitSession, mbDeviceSession, Globals.ImagesDirectory, deviceDllPath, Globals.TestFilePath, Globals.Name, Globals.Address, Globals.Family, Globals.SelectedCalibrationSetup, Globals.StartSetupIndex, Globals.EndSetupIndex, Globals.PrintInformationToFile, Globals.SelectedChannel );

任何人都知道如何防止此异常?

谢谢!

编辑:

完成异常详情:    在System.Environment.GetStackTrace(例外e,布尔needFileInfo)    在System.Environment.get_StackTrace()    在D:\ Dov \ Applications \ AutoCalibration \ AutoCalibration final 20.01.16中的AutoCalibration.Calibration.CalibrationMethod()\ AutoCalibration \ AutoCalibration \ Calibration.cs:第145行    在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)    在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)    在System.Threading.ThreadHelper.ThreadStart()

0 个答案:

没有答案