私はこのコードを持っています:
private void AnswerToCe(int currentBlock, int totalBlock = 0)
{
byte[] bufferToSend;
byte[] macDst = mac;
byte[] macSrc = ConnectionManager.SInstance.GetMyMAC();
byte[] ethType;
byte[] header;
if (Function == FlashFunction.UPLOAD_APPL || Function == FlashFunction.UPLOAD_BITSTREAM)
{
ethType = BitConverter.GetBytes((ushort)EthType.ETH_TYPE_UPLOAD);
ethType = new byte[] { ethType[1], ethType[0] };
header = Header.GetBytes((ushort)binaryBlocks.Count, (ushort)(currentBlock + 1), (ushort)binaryBlocks[currentBlock].Length);
int index = 0;
bufferToSend = new byte[macDst.Length + macSrc.Length + ethType.Length + header.Length + binaryBlocks[currentBlock].Length];
Array.Copy(macDst, 0, bufferToSend, index, macDst.Length);
index += macDst.Length;
Array.Copy(macSrc, 0, bufferToSend, index, macSrc.Length);
index += macSrc.Length;
Logger.SInstance.Write(index.ToString(), "test index pre");
Array.Copy(ethType, 0, bufferToSend, index, ethType.Length);
index += ethType.Length;
Logger.SInstance.Write(index.ToString(), "test index post");
Array.Copy(header, 0, bufferToSend, index, header.Length);
index += header.Length;
Array.Copy(binaryBlocks[currentBlock], 0, bufferToSend, index, binaryBlocks[currentBlock].Length);
}
アプリケーションをデバッグモードでビルドすると、すべて問題なく、test index pre
12をtest index post
出力し、14を出力します。リリースモードでも、Optimize code
チェックを外しても同じです。14ではなく18のOptimize code
チェックtest index post
プリントでテストした
場合。に置き換えindex += ethType.Length;
ても同じ結果になりindex += 2;
ます。動作しているだけのようindex++;index++;
です。
空のアプリケーションでこのコードを試しましたが、合計は問題ありません。
アプリはマルチスレッドですが、ここでは同時実行性はありません。
DLLから逆コンパイルされたコードは問題ないようです。
なぜこれが起こるのか考えはありますか?
編集:アプリがx64用にコンパイルされている場合にのみ発生します。x86は大丈夫です。
編集3:ビルド
環境のいくつかの情報:ビジュアルスタジオ15.0.0-RTW + 26228.4
フレームワーク4.7.02053
は、フレームワーク4.6.2および4.7でこの問題を引き起こす可能性があります。他のフレームワークはテストされていません。
編集5:新しい小さなサンプルプロジェクト。依存関係は必要ありません。
編集6:ここでテストプロジェクトの逆アセンブル。(ここに投稿するには長すぎます)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加