私は .NET で Botan crypto のマネージド ラッパーを構築しており、こちらの開始手順に従っています。
そしてライブラリリファレンス
最初に LibraryInitializer を実行しようとしていますが、それを呼び出すと、INIT() メソッド内で AccessViolationException がスローされます。
私のコードは次のようになります。
C# テスト プログラム
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BotanCrypto_ManagedWrapper;
using System.Numerics;
namespace TestBotanWrapper
{
class Program
{
static void Main(string[] args)
{
BotanCrypto BC = new BotanCrypto();
BC.INIT();
UInt64 num = 100;
BigInteger b = BC.Test(num);
Console.WriteLine(b);
Console.ReadKey();
}
}
}
ラッパー CPP
// This is the main DLL file.
#include "stdafx.h"
#include "BotanCrypto_ManagedWrapper.h"
using namespace BotanCrypto_ManagedWrapper;
void BotanCrypto::INIT(){
LibraryInitializer init;
}
BigInteger BotanCrypto::Test(UInt64 x){
//try{
BigInt n = 1000000;
x = 2;
//}catch(SystemException^ ex){
// x = 0;
//}
return x;
}
ラッパー ヘッダー
// BotanCrypto_ManagedWrapper.h
#pragma once
using namespace System;
using namespace Numerics;
using namespace Botan;
namespace BotanCrypto_ManagedWrapper {
public ref class BotanCrypto
{
// TODO: Add your methods for this class here.
public:
BigInteger Test(UInt64 k);
void INIT();
};
}
ライブラリイニシャライザを正しく呼び出しているかどうかさえわかりません。私は C++ にあまり詳しくありません。どんな助けでも大歓迎です。ありがとう。
EDIT Win32コンソールアプリケーションで同じことを試しましたが、同じ結果が得られました
#include "stdafx.h"
#include <botan/botan.h>
int _tmain(int argc, _TCHAR* argv[])
{
try
{
Botan::LibraryInitializer init;
// ...
}
catch(std::exception& e)
{
//std::cerr << e.what() << "\n";
}
return 0;
}
ConsoleApplication4.exe の 0x0F12422E (botan.dll) で未処理の例外: 0xC0000005: アクセス違反の読み取り場所 0x003B0000。