在c#中访问ms word应用程序

问题描述:

Cannot activate application

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Cannot activate application





i我正在尝试打开一个c#中的word文档。但我的努力是徒劳的。请为我提供更好的解决方案。提前谢谢



i am trying to open a word document in c#. but my hard efforts were in vain. kindly provide me a better solution that works. thanks in advance

这很可能是您的应用程序的权限问题。运行您的应用程序的帐户没有启动应用程序所需的权限:



http://*.com/questions/2690180/com-exception-0x800a11f9-cannot-activate-application [ ^ ]
Most likely this is a permissions problem with your application. The account that your application is running under does not have the permissions necessary to launch the application:

http://*.com/questions/2690180/com-exception-0x800a11f9-cannot-activate-application[^]


您好

这里是我在C#中打开Word文档的解决方案,它是一个带有一个按钮的win form应用程序,您单击以启动打开.txt文档的进程。



Hello
here is my solution for opening Word document in C#, it is win form app with one button on wich you click to start process that opens .txt document.

using System;
using System.Windows.Forms;
using System.Diagnostics;

namespace Open_Word_Document
{
		
   public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
			
		}
		
		void Button1Click(object sender, EventArgs e)
		{
			
			string filePath = "MyDocument.txt";// enter correct path to file with correct extension
			Process open = new Process();
			open.StartInfo.FileName = filePath;
			open.Start();
			open.Dispose();
		}
	}
}


您好,

如果您需要从中读取数据在您的C#项目中的word文档,您可以使用一些第三方.Net组件。它不使用Microsoft Interop,因此您可以避免您提到的问题。如果您正在创建一个非商业项目并使用.docx格式,您可能需要查看 OpenXML [ ^

出于商业目的,我建议你这个

C#Word Reader [ ^ ]

Hello,
If you need to read data from word document in your C# project, you may use some 3rd party .Net components. It does not use Microsoft Interop, so you can avoid the problems you''ve mentioned . If you''re creating a non сommercial project and work with .docx format you may want a look at OpenXML[^].
For commercial purposes i would recommend you this
C# Word Reader[^]