C# Johannes Bildstein的ESDKLib-参数例外;代表必须只有一个目标“;

C# Johannes Bildstein的ESDKLib-参数例外;代表必须只有一个目标“;,c#,multithreading,winforms,delegates,edsdk,C#,Multithreading,Winforms,Delegates,Edsdk,我使用的是Johannes Bildstein先生的Canon SDK示例,但我收到的参数异常消息是“委托人必须只有一个目标。” 当我深入研究时,发现主线程。调用TakePhotoShutterAsync()方法的(()=>引发异常。请告知我如何修复此问题 下面是我的堆栈跟踪 at EOSDigital.API.GeneralExceptionHandler.BeginInvoke(Object sender, Exception ex, AsyncCallback callback, Obje

我使用的是Johannes Bildstein先生的Canon SDK示例,但我收到的参数异常消息是“委托人必须只有一个目标。”

当我深入研究时,发现
主线程。调用
TakePhotoShutterAsync()
方法的(()=>
引发异常。请告知我如何修复此问题

下面是我的堆栈跟踪

at EOSDigital.API.GeneralExceptionHandler.BeginInvoke(Object sender, Exception ex, AsyncCallback callback, Object object)
   at EOSDigital.API.ErrorHandler.ReportError(Object sender, Exception ex)
   at EOSDigital.API.Camera.<TakePhotoShutterAsync>b__80_0(Object state)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   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)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
位于EOSDigital.API.GeneralExceptionHandler.BeginInvoke(对象发送方、异常ex、异步回调、对象对象)
在EOSDigital.API.ErrorHandler.ReportError(对象发送方,异常示例)
在EOSDigital.API.Camera.b_uu80_u0(对象状态)
位于System.Threading.QueueUserWorkItemCallback.WaitCallback_上下文(对象状态)
位于System.Threading.ExecutionContext.RunInternal(ExecutionContext ExecutionContext、ContextCallback回调、对象状态、布尔值preserveSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔保存SyncCTX)
位于System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()处
在System.Threading.ThreadPoolWorkQueue.Dispatch()中
在System.Threading.\u ThreadPoolWaitCallback.PerformWaitCallback()中
下面是我得到异常的完整方法

/// <summary>
    /// Takes a photo with the current camera settings asynchronously with the PressShutterButton command
    /// </summary>
    /// <exception cref="ObjectDisposedException">Camera is disposed</exception>
    /// <exception cref="CameraSessionException">Session is closed</exception>
    /// <exception cref="SDKStateException">Canon SDK is not initialized</exception>
    public void TakePhotoShutterAsync()
    {
        CheckState();
        ThreadPool.QueueUserWorkItem((state) =>
        {
            try
            {
                MainThread.Invoke(() =>
                {
                    SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely);
                    SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF);
                });
            }
            catch (Exception ex) { err.writeError(ex.Message); if (!ErrorHandler.ReportError(this, ex)) throw; }
        });
    }
//
///使用PressShutterButton命令以当前相机设置异步拍照
/// 
///摄像机被配置好了
///会议结束
///佳能SDK未初始化
public void TakePhotoShutterAsync()
{
CheckState();
ThreadPool.QueueUserWorkItem((状态)=>
{
尝试
{
MainThread.Invoke(()=>
{
SendCommand(CameraCommand.PressShutterButton,(int)ShutterButton.Complete);
Send命令(CameraCommand.PressShutterButton,(int)ShutterButton.OFF);
});
}
catch(Exception ex){err.writeError(ex.Message);if(!ErrorHandler.ReportError(this,ex))throw;}
});
}

如果出现异常,请始终发布堆栈跟踪。@Voo更新了堆栈跟踪,谢谢!看起来您多次订阅了ErrorHandler.SevereErrorOccessed事件,并且其中一个SendCommand方法中存在异常。您应该能够订阅多次,这是我的一个错误。作为一种解决方法,订阅只有一次。您在最近的编辑中更新过它吗?如果有异常,请始终发布堆栈跟踪。@Voo更新了堆栈跟踪,谢谢!看起来您已多次订阅ErrorHandler.SevereErrorOccessed事件,并且其中一个SendCommand方法中存在异常。您应该能够订阅多次,这是一个错误就我而言。作为一种解决办法,只订阅一次。您在最近的编辑中更新过它吗?