获取试图使用Word的DocumentClass只有在督促一个对象引用错误对象、错误、Word、DocumentClass

2023-09-04 00:41:43 作者:江畔旧时月

我写一个使用.DOTX模板,做数据的合并在一个aspx页面的程序。该项目工程完美的我的开发工作站上本地,但是当我将其部署到测试IIS服务器,它无法在第二行下面给我一个对象引用错误。

我遇到了问题,早期因为这个词的COM对象不是IIS服务器上,所以我装字到服务器,并设置权限的DCOM,并获得过去的这个问题。但现在我得到了与wRange开头的行此错误= .....

正如我所说,该计划完美的作品在本地调试模式。

任何想法?

  Microsoft.Office.Interop.Word.DocumentClass

System.NullReferenceException:对象未设置为一个对象的实例
 

的code线:

 文件BaseDocument = oWord.Documents.Open(REF oTemplate,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing ,REF oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing,裁判oMissing);

wRange = BaseDocument.Bookmarks.get_Item(REF endOfDoc).Range;
 

解决方案 单击开始,单击程序,单击管理工具,单击组件服务。 展开组件服务,展开计算机,展开我的电脑,展开DCOM配置,并用鼠标右键点击微软的Word 97 - 2003文档。选择属性。 单击常规。设置身份验证级别设置为连接(没有也可以)。 单击身份。设置此用户。指定将始终使用不管是哪个用户访问它运行的COM应用程序的用户帐户。 单击按钮完成操作。 单击OK按钮。 ◦For上的DCOM配置远程访问访问的 的https://danieladeniji.wordpress.com /配置-DCOM换远程访问/ Microsoft Word Document怎么弄掉

I am writing a program that uses a .dotx template and does a merge of data in an aspx page. The program works perfect on my Dev workstation locally but when I deploy it to a test IIS server, it fails on the second line below giving me an Object Reference error.

I ran into problems earlier because the Word Com object was not on the IIS server so I loaded Word onto the server and set permission in DCom and got past that problem. But now I get this error on the line that starts with wRange = .....

As I said, the program works perfectly locally in debug mode.

Any ideas?

Microsoft.Office.Interop.Word.DocumentClass

System.NullReferenceException: Object reference not set to an instance of an object

lines of code:

Document BaseDocument = oWord.Documents.Open(ref oTemplate, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

wRange = BaseDocument.Bookmarks.get_Item(ref endOfDoc).Range;

解决方案

Click Start, click Programs, click Administrative Tools, click Component Services. Expand Component Services, expand Computers, expand My Computer, expand DCOM Config, and right-click Microsoft Word 97 - 2003 Document. Select Properties. Click General. Set Authentication Level to Connect (None also work). Click Identity. Set This user. Specify a user account that will always be used to run the COM application regardless of which user is accessing it. Click button Apply. Click button OK. ◦For more information on "Configuring DCOM for Remote Access" visit https://danieladeniji.wordpress.com/configuring-dcom-for-remote-access/