を管理しますが、私はまだそれを得ることはありませんDLLによって駆動されるRFIDリーダ。このDLLのソースコードはありませんが、使用方法を示すサンプルのみです。GCHandle、私が働いている</p> <p>....のAppDomainは「AppDomainを越えてGCHandleを渡すことはできません」私は例外についての多くのスレッドを見てきたコードやサードパーティ製のDLL
サンプルは素晴らしいですが、別のプロジェクトでコードをコピーして、ミドルウェアMicrosoft Biztalkにリーダーを追加する必要があります。
問題は、Microsoft Biztalkのプロセスが別のAppDomainで動作することです。リーダは、タグが読み取られたときのイベントを処理します。しかし、Microsoft Biztalkの下で実行すると、この迷惑な例外が発生します。
私はそれを動作させる方法に関するすべてのソリューションを見ることができない...
ここでは面白いかもしれいくつかのコードです:
// Let's connecting the result handlers.
// The reader calls a command-specific result handler if a command is done and the answer is ready to send.
// So let's tell the reader which functions should be called if a result is ready to send.
// result handler for reading EPCs synchronous
Reader.KSRWSetResultHandlerSyncGetEPCs(ResultHandlerSyncGetEPCs);
[...]
var readerErrorCode = Reader.KSRWSyncGetEPCs();
if (readerErrorCode == tKSRWReaderErrorCode.KSRW_REC_NoError)
{
// No error occurs while sending the command to the reader. Let's wait until the result handler was called.
if (ResultHandlerEvent.WaitOne(TimeSpan.FromSeconds(10)))
{
// The reader's work is done and the result handler was called. Let's check the result flag to make sure everything is ok.
if (_readerResultFlag == tKSRWResultFlag.KSRW_RF_NoError)
{
// The command was successfully processed by the reader.
// We'll display the result in the result handler.
}
else
{
// The command can't be proccessed by the reader. To know why check the result flag.
logger.error("Command \"KSRWSyncGetEPCs\" returns with error {0}", _readerResultFlag);
}
}
else
{
// We're getting no answer from the reader within 10 seconds.
logger.error("Command \"KSRWSyncGetEPCs\" timed out");
}
}
[...]
private static void ResultHandlerSyncGetEPCs(object sender, tKSRWResultFlag resultFlag, tKSRWExtendedResultFlag extendedResultFlag, tKSRWEPCListEntry[] epcList)
{
if (Reader == sender)
{
// Let's store the result flag in a global variable to get access from everywhere.
_readerResultFlag = resultFlag;
// Display all available epcs in the antenna field.
Console.ForegroundColor = ConsoleColor.White;
foreach (var resultListEntry in epcList)
{
handleTagEvent(resultListEntry);
}
// Let's set the event so that the calling process knows the command was processed by reader and the result is ready to get processed.
ResultHandlerEvent.Set();
}
}
まずはお返事ありがとうございます。実際には、私はdllからオブジェクトをinstanciatingに成功し、それを使用します。上記のコードでわかるように、タグを読み取るときにリーダーが送信するイベントにメソッド(ResultHandlerSyncGetEPCs)を接続します。イベントが来るのを待っている行のソースコードがクラッシュする...タイムアウトのために少なくとも10秒待たずに、すぐに「GCHandle ...を渡すことはできません」という例外がスローされます。 – hurtauda
そして、この時点でアンテナ上のタグを読み取っているため、リーダーが正しく接続されていて、 'Reader.KSRWSyncGetEPCs();' というメソッドを受け取ることができます。 – hurtauda
私は、問題の原因を診断するための特別な勧告をしました。これを追求したくない場合は、ベンダーに直接サポートを依頼してください。 –