首页 新闻 会员 周边

C#生成的dll(引用了office的com控件实现文档转换),PHP调用时出现问题?

0
悬赏园豆:15 [已解决问题] 解决于 2013-04-15 09:34

C#生成dll,其中引用了office的com控件实现文档转换。

当其他winform程序调用时正常。

但注册该dll后,由PHP调用时出错。

try catch了一下,输出“Word 出现问题”。

测试机器上装的是office2007。C#实现文档转换部分:

          string fileFolder = Path.GetDirectoryName(wordFilePath);
          string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(wordFilePath);
          string htmlFilePath = fileFolder + @"\" + fileNameWithoutExtension + @".html";

          Object objWordPath = wordFilePath;
          Object objHtmlPath = htmlFilePath;
          MSWord.Application wordApp;
          MSWord.Document wordDoc;
          Object Nothing = Missing.Value;
          wordApp = new MSWord.ApplicationClass();
          wordDoc = wordApp.Documents.Add(ref objWordPath, ref Nothing, ref Nothing, ref Nothing);//===========PHP调用时这下面的语句执行不到
          object format = MSWord.WdSaveFormat.wdFormatFilteredHTML;
          wordDoc.SaveAs(ref objHtmlPath, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
            ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
          wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
          wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);

dll注册后,PHP调用部分:

<?php
$c= new COM("ComLibrary.Test");
echo $c->SaveWordAsHtml("D:\\ningtao\\xampp\\htdocs\\test.doc");
?>

不知道是由什么引起的。

初步怀疑有2中可能:

1、dll注册为COM+再被PHP调用时,没有正确的调用office的com组件。

2、被PHP调用时,由于文件的读写权限引起的问题。

 

大家有没有遇到过类似问题的,该如何解决?

geeksnail的主页 geeksnail | 菜鸟二级 | 园豆:368
提问于:2013-04-02 17:05
< >
分享
最佳答案
0

自己解决
相关网址:http://blog.csdn.net/yeness/article/details/7754486
设置一下office的com组件的访问权限就好了。

geeksnail | 菜鸟二级 |园豆:368 | 2013-04-15 09:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册