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 –