1
我已經使用GemBox.Document編寫了一個包含接口的c#包裝類來完成文檔轉換。在課堂上,我有以下方法來保存文件:在GemBox.Document.dll中發生未處理的類型'System.StackOverflowException'的異常
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並創建了一個TLB文件與regasm如下:
regasm MBD.GemBox.Document.dll /tlb
我想通過德爾福COM訪問的dll,所以我進口TLB文件到德爾福2009年我然後創建調用C#DLL的包裝德爾福庫:
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;
不過,我得到了
「未處理在GemBox.Document.dll中發生類型'System.StackOverflowException'異常「
當我嘗試通過delphi調用該方法時。有誰知道爲什麼發生這種情況?
您需要調試您的代碼。看來你有一個堆棧溢出錯誤。 –
如果您只是將WordDocuments轉換爲另一種類型,您可能會喜歡此https://github.com/tobya/DocTo –