GemBox.Document を使用してドキュメント変換を行うためのインターフェイスを備えた ac# ラッパー クラスを作成しました。クラスには、ドキュメントを保存する次のメソッドがあります。
public string SourcePath{get;set;}
public string DestinationType{get;set;}
public string DestinationPath{get;set;}
private static DocumentModel document;
public void ConvertDocument()
{
try
{
string filename = Path.GetFileNameWithoutExtension(SourcePath);
ComponentInfo.SetLicense(GemboxLicence);
string savePath = String.Format("{0}\\{1}.{2}", DestinationPath, filename, DestinationType);
document = DocumentModel.Load(SourcePath);
document.Save(savePath);
}
catch (Exception e)
{
throw (new Exception("An error occured while saving the document: " + e.Message ));
}
}
別の C# プログラムから呼び出すと、クラスは正常に動作します。
クラスの dll を com に登録し、次のように regasm で tlb ファイルを作成しました。
regasm MBD.GemBox.Document.dll /tlb
Delphi から com を介して dll にアクセスしたかったので、tlb ファイルを Delphi 2009 にインポートしました。次に、c# dll を呼び出すラッパー Delphi ライブラリを作成しました。
procedure ConvertDocument(sourcePath : string ; destinationType : string ; destinationPath : string);
var
doc : TDocumentConvertor;
begin
try
OleInitialize(nil);
doc := TDocumentConvertor.Create(nil);
doc.Connect;
doc.SourcePath := sourcePath ;
doc.DestinationType := destinationType;
doc.DestinationPath := destinationPath;
doc.ConvertDocument;
doc.Disconnect;
doc.Free;
CoUninitialize;
except
on E:Exception do
begin
Writeln(E.Classname, ': ', E.Message);
end;
end;
end;
しかし、私は
「タイプ 'System.StackOverflowException' の未処理の例外が GemBox.Document.dll で発生しました」
デルファイを介してメソッドを呼び出そうとすると。なぜこれが起こるのか誰か知っていますか?