如何将回拨委托传递给.netCF中的dll
问题描述:
我正在编写一个.netCF应用程序,该应用程序在不同硬件平台上与条形码扫描器进行接口连接。 I. E.摩托罗拉或Intermec等我用自己的DLL包装了一个公共接口,我在运行时使用Reflection LoadFrom()加载我的dll,然后获取一个Method引用。如何将回拨委托传递给.netCF中的dll
我能够将大多数参数传递给我的DLL中的方法,但有一个例外。我需要将回调函数传递给dll,以便在发生读取时将回调到主程序中以处理读取的条形码。
当我调用该方法时,它抛出一个ArgumentException。
我的问题是如何将此方法引用传递给我的dll,或者有没有更好的方法来做到这一点?
public delegate void ReadNotify(BCReadData readData);
public void AttachReadNotify(ReadNotify ReadNotifyHandler)
{
if (type == ReaderType.UNKNOWN || scanIntf == null)
return;
try
{
setReadNotify.Invoke(scanIntf,new Object [] {ReadNotifyHandler});
}
catch (Exception e)
{
throw new Exception("Unable to set notify handler" + e.Message);
}
}
你的本地方法的签名是怎样的? – Groo