Word system runtime interopservices comexception

public static Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
        public static string generalfile = Application.StartupPath + "\Shablon\1.docx"; // файл-шаблон
        public static string newfile = Application.StartupPath + "\" + Program.namePath + "\протокол1.docx"; // новый файл на основе файла-шаблона
        public static Object fileName = generalfile;
        public static Object missing = Type.Missing;
        public void OpenFile()
        {
            app.Documents.Open(ref fileName);
        }
        public void SaveCloseFile()
        {
            app.ActiveDocument.SaveAs(newfile);
            app.ActiveDocument.Close();
            app.Quit();
        }
        public void FindReplace(string str_old, string str_new)
        {
            Microsoft.Office.Interop.Word.Find find = app.Selection.Find;

            find.Text = str_old; // текст поиска
            find.Replacement.Text = str_new; // текст замены

            find.Execute(FindText: Type.Missing, MatchCase: false, MatchWholeWord: false, MatchWildcards: false,
                        MatchSoundsLike: missing, MatchAllWordForms: false, Forward: true, Wrap: Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue,
                        Format: false, ReplaceWith: missing, Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

        }

При повторном создание файла ругается на метод openFile исключением System.Runtime.InteropServices.COMException.

Сам вызов:

OpenFile();
FindReplace("name", Program.namePath);
FindReplace("Predsedatel", predsedatel_name + " - " + dolzhnostPred);
FindReplace("V1", textBox6.Text.Trim());
FindReplace("V2", textBox7.Text.Trim());
FindReplace("V3", textBox8.Text.Trim());
FindReplace("Com1", comissionname[0] + " - " + dolzhnostCom[0]);
FindReplace("Com2", comissionname[1] + " - " + dolzhnostCom[1]);
FindReplace("Com3", comissionname[2] + " - " + dolzhnostCom[2]);
FindReplace("Com4", comissionname[3] + " - " + dolzhnostCom[3]);
FindReplace("Secretar", secretar_name + " - " + dolzhnostSec);
FindReplace("ocenkaGos", Program.ocenkaGos + " %");
SaveCloseFile();

  • Remove From My Forums
  • Question

  • Hi Guys, not sure if this is the correct forum.  If not, can someone please point me in the right direction.  I’m trying to open MS word using Microsoft.Office.Interop.Word in my project. I don’t write many code in my project. I just write below
    code and start face with below error message when i run on test PC.

    System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154
    (REGDB_E_CLASSNOTREG)).

    Here is my sample code in my project

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Word = Microsoft.Office.Interop.Word;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                Word.Application _appl = new Word.Application();            
                _appl.Quit();
            }
        }
    }

    I’m looking over Google and bing but still cannot find and solve this problem and can’t go forward. My test PC does not install office and i installed «Microsoft Office 2010: Primary Interop Assemblies Redistributable». I don’t see any Microsoft.Office.Interpo
    in «C:Windowsassembly» after i install «Microsoft Office 2010: Primary Interop Assemblies Redistributable». So i use gacutil.exe to install the dll. I choose x86 platform when i build my project. But still cannot run my sample project.

    Regards,

    Yukon


    Make Simple & Easy

Answers

  • Hello Yukon,

    80040154 Class not registered (Exception from
    HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

    It states that you don’t have a corresponding Office application
    installed (registered) on the computer. You need to install Office/Word to be able to debug the code.

    Interop libraries are just used for marshaling your property
    or method calls to the unmanaged classes (COM servers). So, they are not a panacea. Install the application first.

    • Marked as answer by

      Tuesday, September 8, 2015 1:58 AM

  • Hi Yukonn

    Eugene intimates what the problem is, but doesn’t come right out and say it:

    You cannot automate Office without the Office application being installed. Office does not provide and «libraries» the developer can use without the licensed and installed desktop version of Office.

    Further, you should install the oldest version of Office your application will be targeting. Note that you may need to remove the PIAs you installed if they do not match the version of Office you install, otherwise there could be conflicts in the Windows
    Registry.


    Cindy Meister, VSTO/Word MVP,
    my blog

    • Marked as answer by
      Yukonn
      Tuesday, September 8, 2015 1:58 AM

  • Remove From My Forums
  • Question

  • We have a word based application. We create a Word Addin & when trying to connect the addin using the statements :

    Microsoft.Office.Core.COMAddIn MyAddin = null;
                bool bFound = false;
                try
                {
                    foreach (Microsoft.Office.Core.COMAddIn MyAddin1 in WordApp.COMAddIns)
                    {
                        MyAddin = MyAddin1;
                        if (MyAddin.Description == "My ComAddin")
                        {
                            MyAddin.Connect = true;
                            bFound = true;
                            break;
                        }
                }
             }

    Just as the code hits the line MyAddin.Connect
    = true;
     it throws the below exception:-

    A first chance exception of type ‘System.Runtime.InteropServices.COMException’ occurred in MyWordApp.exe Additional information: Error in the DLL (Exception from HRESULT: 0x800401F9 (CO_E_ERRORINDLL)) & the Word application quits after this.

    I googled to find some resolution to this but to no help. Can anyone help me on this to avoid the exception.

    Thanks/Saurav.


    Suarav

    • Edited by

      Thursday, December 12, 2013 4:25 AM

Table of Contents

  • The problem(s)
  • The Fix(es)
    • 80040154 Class not registered
    • 80070005 Access denied
    • RPC_E_SERVERCALL_RETRYLATER
    • The RPC server is unavailable
    • 0x800A03EC Cannot access the file
  • Conclusion

If you’ve stumbled upon this post you’re most likely dealing with the Microsoft Office primary interop assemblies (PIAs), also known as Microsoft.Office.Interop library set. This is a neat collection of libraries, released by Microsoft through NuGet, which can be used to programmatically access — open, edit, save, create and so on — Microsoft Office files such as: xls / xlsx (Excel), doc / docx (Word), mdb (Access) and so on.

In case you also need a tutorial / coding sample about how to implement Microsoft.Office.Interop library set in a typical ASP.NET C# application, we suggest to read this post: here we’ll take for granted that you’ve already did something like that and you’re trying to publish it onto a production IIS server machine — arguably, without success.

The problem(s)

As soon as you install these assemblies in your developer machine you’ll be able to deal with the Office files without issues. However, when you’ll eventually want to publish your efforts in a production server (Windows Server + IIS), you might deal with one of the following errors:

System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

or:

System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access denied. (Eccezione da HRESULT: 0x80070005 (E_ACCESSDENIED))

or:

System.Runtime.InteropServices.COMException: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

or:

System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

or:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file

These are the most common errors you might encounter when dealing with Microsoft.Office.Interop: luckily enough, there’s a quick solution for each one of them.

The Fix(es)

Let’s start with the easy one.

80040154 Class not registered

If you’re hitting the 80040154 Class not registered error, it probably just means that Microsoft Office isn’t installed on your IIS server machine. Yeah, that’s about it! If you thought that you could avoid installing it, you were wrong: a locally-installed instance of Microsoft Office is required to use the Microsoft.Office.Interop libraries, because they basically launch the actual MS Office apps in background to handle the calls.

As a matter of fact, they also do that in an highly-inefficient way, often messing up with the multi-thread context of a typical Web Application — that’s why you should use
lock ,
Monitor.TryEnter  or other similar methods to synchronize access to these kind of calls. We won’t expand such topic here any further, but you can see a sample lockers implementation / tutorial / code sample in this post.

80070005 Access denied

This error basically means that the web site is definitely finding the COM objects related to the MS Office application you want to execute, but the Application Pool in charge of the running process doesn’t have permissions to use them. In order to fix that, follow these steps:

  • Open IIS Manager > Application Pools and identify the identity assigned to the Application Pool assigned to the web application (it’s in the Advanced Properties tab). Keep a note of that user (or system) account, because you’ll need it later on. If you fond the ApplicationPoolIdentity there, you need to do some little extra-work: as you might know, that user it’s a dynamically created, unprivileged account: to change its permissions in the following steps, you’ll need to look-up for the IIS AppPool[AppPoolName] role. If that’s too much for you to handle, you can change the identity to a «static» account… but you shouldn’t do that, as the ApplicationPoolIdentity usage is a best practice to deal with IIS7+ / IIS8+ Application Pools in a secure way. For additional info on that topic, read this StackOverflow thread.
  • Launch the
    dcomcnfg  command from Windows > StartRun or from a command-prompt: go to Component Services > Computers > My Computer > DCOM Config, then locate the various «Microsoft XYZ Document» and/or «Microsoft XYZ Application» entries, where XYZ are Word, Excel and/or Access — depending on what you need to access programmatically from your ASP.NET web application: you’ll need to perform the following tasks for each one of them.
  • Right-click the entry and select Properties:
    • Go to the Identity tab, where you’ll see three radio buttons: The Interactive User, The Launching User and This User. Select This User, then put the credentials of the account who installed MS Office — or an administrative account.
    • Go to the Security tab, where you’ll find three group boxes: for the first two of them — Launch and Activation Permissions and Access Authorization —  select the Customize radio button, then add the same identity that runs your web site’s Application Pool — the one which you took note of few minutes ago. In some scenarios, depending on the Windows Server version, you’ll also need to add the IUSR and IUSR_[MACHINENAME] accounts.

IMPORTANT: in case the DCOM Config panel does not contain any «Microsoft XYZ Document» and/or «Microsoft XYZ Application«, it’s most likely due to the fact that a 32-bit MS Office version has been installed on a 64-bit server machine: if that’s the case, we’ll need to launch the snap-in in 32-bit mode by using the following command:

For additional info regarding this topic, you can take a look at this MS TechNet article.

RPC_E_SERVERCALL_RETRYLATER

This error message is strictly related to the fact that we’re trying to use the Microsoft.Office.Interop libraries in a multi-thread environment: if you see this, it probably means that two (or more) users are trying to create an instance of the same Office.Interop object, which cannot be done. The fix is to just implement a way to queue such requests by using  
lock ,
Monitor.TryEnter  or other similar methods (see this post for a quick implementation / code sample).

The RPC server is unavailable

The error 0x800706BA usually happens when the RPC Locator / RPC Endpoint Mapper windows service is not running. To fix that, just open Control Panel > Administrative Tools > Services and manually launch it. In case this is enough to fix your issue, remember to switch its starting behavior from Manual to Automatic to prevent your Web Application’s interop-based feature from ceasing to work (again) upon the next machine reboot.

0x800A03EC Cannot access the file

The 0x800A03EC Cannot access the file is arguably the worst error you can experience, as the given error message is completely misleading. To fix that, you have to do the following:

  • Create the following new folders on your Windows Server + IIS machine:
    • C:WindowsSysWOW64configsystemprofileDesktop (for 64-bit Servers only)
    • C:WindowsSystem32configsystemprofileDesktop (for both 32-bit and 64-bit Servers)
  • Set Full control permissions for these Desktop folders for the Application Pool user (IIS AppPoolDefaultAppPool if you’re using the ApplicationPoolIdentity dynamic account).

That’s it for now: I sincerely hope that this post will help most developers who’re struggling against the adversities of the dreadful Microsoft.Office.Interop ASP.NET library package!

Conclusion

That’s it: we hope that this post will help other software developers to get rid of these nasty interop-based issues: if you found this post useful for your scenario, don’t forget to let us know in the comments section below (and like us on Facebook and Twitter, if you don’t mind): doing that won’t cost you a penny, and will greatly help us to keep writing these guides. Thanks in advance!

Собственно есть документ Word, в котором записан некоторый текст и несколько таблиц. Требуется изменить стили текста и таблиц. И если изменением текста всё понятно и вполне даже получается, то вот с таблицами полный ноль.

Пытаюсь получить таблицу так:

Word.Range rng = document.Paragraphs[1].Range;
Word.Table tbl = rng.Tables[1];

Но выдаёт ошибку:

System.Runtime.InteropServices.COMException: «Запрашиваемый номер семейства не существует.»


  • Вопрос задан

    более трёх лет назад

  • 188 просмотров

совет — включите запись макросов, проделайте манипуляции с таблицей, те самые что хотите автоматизировать, завершите запись, откройте VBA и переведите с VB на шарп, то что будет в записи

довольно универсальный рецепт, при работе с офисом

ps правда перевод не всегда абсолютно очевиден.. но можно достаточно быстро освоится

Пригласить эксперта

Замените rng на document
Word.Table tbl = document.Tables[1];


  • Показать ещё
    Загружается…

15 апр. 2023, в 02:02

12000 руб./за проект

14 апр. 2023, в 23:12

8000 руб./за проект

14 апр. 2023, в 23:01

10000 руб./за проект

Минуточку внимания

Коллеги, как показала практика ошибка не из за библиотеки. Причем на 2 разных компьютерах выдает разные исключения. Приводу полный текст сообщений. Прошу помочь с решением вопроса.
Ошибка System.Runtime.InteropServices.COMException (0x80010105): Ошибка на сервере. (Исключение из HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

Кликните здесь для просмотра всего текста

Подробная информация об использовании оперативной
(JIT) отладки вместо данного диалогового
окна содержится в конце этого сообщения.
************** Текст исключения **************
System.Runtime.InteropServices.COMException (0x80010105): Ошибка на сервере. (Исключение из HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
в Microsoft.Office.Interop.Excel.Workbooks.Open(Stri ng Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
в AvantekProjectSummary.FormMain.Button1_Click(Objec t sender, EventArgs e)
в System.Windows.Forms.Control.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnClick(EventArgs e)
в System.Windows.Forms.Button.PerformClick()
в AvantekProjectSummary.FormMain.Button5_Click(Objec t sender, EventArgs e)
в System.Windows.Forms.Control.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
в System.Windows.Forms.Control.WndProc(Message& m)
в System.Windows.Forms.ButtonBase.WndProc(Message& m)
в System.Windows.Forms.Button.WndProc(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Загруженные сборки **************
mscorlib
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
—————————————-
Avantek Project Summary
Версия сборки: 1.0.0.0
Версия Win32: 1.0.0.0
CodeBase: file:///Z:/%D0%9F%D1%80%D0%BE%D0%BC%D0%B8%D0%BD%D0%B4%D1%83%D 1%81%D1%82%D1%80%D0%B8%D1%8F/%D0%9B%D0%B8%D1%87%D0%BD%D1%8B%D0%B5%20%D0%BF%D0%B 0%D0%BF%D0%BA%D0%B8/%D0%A4%D0%B5%D0%B4%D0%BE%D1%81%D0%BE%D0%B2%20%D0%9 0%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B9%20%D0%9D%D0% B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%B8%D1%87/Avantek%20Project%20Summary/Avantek%20Project%20Summary.exe
—————————————-
Microsoft.VisualBasic
Версия сборки: 10.0.0.0
Версия Win32: 14.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
—————————————-
System
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
—————————————-
System.Core
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3190.0 built by: NET472REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
—————————————-
System.Windows.Forms
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
—————————————-
System.Drawing
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
—————————————-
System.Configuration
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
—————————————-
System.Xml
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
—————————————-
System.Runtime.Remoting
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
—————————————-
Microsoft.Office.Interop.Excel
Версия сборки: 15.0.0.0
Версия Win32: 15.0.4569.1506
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
—————————————-
office
Версия сборки: 15.0.0.0
Версия Win32: 15.0.4613.1000
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
—————————————-
System.Windows.Forms.resources
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Windows.Forms.resources.dll
—————————————-
mscorlib.resources
Версия сборки: 4.0.0.0
Версия Win32: 4.7.3056.0 built by: NET472REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/mscorlib.resources.dll
—————————————-
************** Оперативная отладка (JIT) **************
Для подключения оперативной (JIT) отладки файл .config данного
приложения или компьютера (machine.config) должен иметь
значение jitDebugging, установленное в секции system.windows.forms.
Приложение также должно быть скомпилировано с включенной
отладкой.
Например:
<configuration>
<system.windows.forms jitDebugging=»true» />
</configuration>
При включенной отладке JIT любое необрабатываемое исключение
пересылается отладчику JIT, зарегистрированному на данном компьютере,
вместо того чтобы обрабатываться данным диалоговым окном.

System.Runtime.InteropServices.COMException (0x80010001): Вызов был отклонен. (Исключение из HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

Кликните здесь для просмотра всего текста

Подробная информация об использовании оперативной
(JIT) отладки вместо данного диалогового
окна содержится в конце этого сообщения.

************** Текст исключения **************
System.Runtime.InteropServices.COMException (0x80010001): Вызов был отклонен. (Исключение из HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
в System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
в System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
в Microsoft.VisualBasic.CompilerServices.VBBinder.In vokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters)
в Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
в Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
в AvantekProjectSummary.ModuleSubProgramm.CheckCalcE nd(Object intRowsNomber, Object oExcelCalc)
в AvantekProjectSummary.FormMain.Button1_Click(Objec t sender, EventArgs e)
в System.Windows.Forms.Control.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnClick(EventArgs e)
в System.Windows.Forms.Button.PerformClick()
в AvantekProjectSummary.FormMain.Button5_Click(Objec t sender, EventArgs e)
в System.Windows.Forms.Control.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
в System.Windows.Forms.Control.WndProc(Message& m)
в System.Windows.Forms.ButtonBase.WndProc(Message& m)
в System.Windows.Forms.Button.WndProc(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Загруженные сборки **************
mscorlib
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
—————————————-
Avantek Project Summary
Версия сборки: 1.0.0.0
Версия Win32: 1.0.0.0
CodeBase: file:///Z:/%D0%9F%D1%80%D0%BE%D0%BC%D0%B8%D0%BD%D0%B4%D1%83%D 1%81%D1%82%D1%80%D0%B8%D1%8F/%D0%9B%D0%B8%D1%87%D0%BD%D1%8B%D0%B5%20%D0%BF%D0%B 0%D0%BF%D0%BA%D0%B8/%D0%A4%D0%B5%D0%B4%D0%BE%D1%81%D0%BE%D0%B2%20%D0%9 0%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B9%20%D0%9D%D0% B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%B8%D1%87/Avantek%20Project%20Summary/Avantek%20Project%20Summary.exe
—————————————-
Microsoft.VisualBasic
Версия сборки: 10.0.0.0
Версия Win32: 14.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
—————————————-
System
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
—————————————-
System.Core
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
—————————————-
System.Windows.Forms
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
—————————————-
System.Drawing
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
—————————————-
System.Configuration
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
—————————————-
System.Xml
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
—————————————-
System.Runtime.Remoting
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
—————————————-
Microsoft.Office.Interop.Excel
Версия сборки: 15.0.0.0
Версия Win32: 15.0.4569.1506
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
—————————————-
office
Версия сборки: 15.0.0.0
Версия Win32: 15.0.4613.1000
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
—————————————-
System.Windows.Forms.resources
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/System.Windows.Forms.resources.dll
—————————————-
mscorlib.resources
Версия сборки: 4.0.0.0
Версия Win32: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_ru_b77a5c561934e089/mscorlib.resources.dll
—————————————-

************** Оперативная отладка (JIT) **************
Для подключения оперативной (JIT) отладки файл .config данного
приложения или компьютера (machine.config) должен иметь
значение jitDebugging, установленное в секции system.windows.forms.
Приложение также должно быть скомпилировано с включенной
отладкой.

Например:

<configuration>
<system.windows.forms jitDebugging=»true» />
</configuration>

При включенной отладке JIT любое необрабатываемое исключение
пересылается отладчику JIT, зарегистрированному на данном компьютере,
вместо того чтобы обрабатываться данным диалоговым окном.

I am getting this stacktrace:

System.Runtime.InteropServices.COMException (0x800A13E9): Word ðú÷ì ááòéä.
   at Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible)
   at Crm.DocumentGeneration.Printing.DocumentsPrinter.MergeDocuments(ApplicationClass& wordApp, IEnumerable`1 printDataItems, String tempDirectory, String template) in C:WorkDanel.NursingCrm.DocumentGeneration.PrintingDocumentsPrinter.cs:line 249

After googling a bit it seems that COMException (0x800A13E9) is out of memory exception but there is enough memory on the server to launch a spaceship 8192 spaceships.
Here is the function call:

Document document = wordApp.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing);

Nothing is null or invalid with defaultTemplate, I checked.

  • Справка
  • Сервисы
  • Известные проблемы

Известные проблемы

В данном разделе рассматриваются возможные проблемы в работе приложения и описываются способы решения
этих проблем.

Исключение из HRESULT: 0x800A175D

Тип ошибки: System.Runtime.InteropServices.COMException

Ошибка возникает при формировании отчёта Word.

Возможные причины:

В приложении Microsoft Office включен режим защищенного просмотра.

Решение:

Открыть Microsoft Word (MS Excel);

Войдите в Параметры;

Нажмите Центр управления безопасностью, а затем нажмите кнопку Параметры центра;

Нажмите параметры защищенного просмотра. Снимите галочку со следующих элементов:

— Включить режим защищенного просмотра для файлов, исходящих из Интернета;

— Включить режим защищенного просмотра для файлов, расположенных в потенциально опасных местах;

— Включить режим защищенного просмотра для вложений Outlook;

Выберите OK.

Указанному файлу не сопоставлено ни одно приложение для выполнения данной операции

Тип ошибки: System.ComponentModel.Win32Exception

Ошибка возникает при попытке открыть веб-страницы через меню приложения StatUs.

Например, при выборе меню «Сервис -> Активация -> Добавить этот компьютер в систему лицензирования».

Возможные причины:

На Вашем компьютере не назначен браузер по умолчанию.

Решение:

Настроить браузер по умолчанию на Вашем компьютере и повторить попытку.

Подробнее об настройке браузера по умолчанию можно прочитать, например, здесь.

Не удается открыть банк макросов

Тип ошибки: System.Runtime.InteropServices.COMException

Ошибка возникает при формировании отчёта Word.

Возможные причины:

В приложении Microsoft Office включен режим защищенного просмотра.

Решение:

Открыть Microsoft Word;

Войдите в Параметры;

Нажмите Центр управления безопасностью, а затем нажмите кнопку Параметры центра;

Нажмите параметры защищенного просмотра. Снимите галочку со следующих элементов:

— Включить режим защищенного просмотра для файлов, исходящих из Интернета;

— Включить режим защищенного просмотра для файлов, расположенных в потенциально опасных местах;

— Включить режим защищенного просмотра для вложений Outlook;

Выберите OK.

Не удалось получить фабрику класса COM

Тип ошибки: System.Runtime.InteropServices.COMException

Ошибка возникает при формировании отчёта Word.

Возможные причины:

На Вашем компьютере установлена версия Microsoft Office с ограниченной функциональностью.

В частности, ограниченной функциональностью обладает версия Microsoft Office Starter.

Решение:

Убедитесь, что на Вашем компьютере установлена версия Microsoft Office, не имеющая ограничения
функциональности приложения Word, и повторите попытку.

Не удалось выполнить экспорт, поскольку этот компонент не установлен.

Тип ошибки: System.Runtime.InteropServices.COMException

Ошибка возникает при формировании отчёта PDF при использовании Microsoft Word 2007.

Возможные причины:

По умолчанию Microsoft Word 2007 не поддерживает сохранение в формате PDF.

Решение:

Необходимо установить
дополнительную надстройку от Microsoft
для сохранения в формате PDF.

Попробуйте установить эту надстройку и повторить попытку.

Не удалось получить фабрику класса COM для компонента с CLSID {000209FF-0000-0000-C000-000000000046} из-за следующей ошибки: 80040154 Класс не зарегистрирован (Исключение из HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Тип ошибки: System.Runtime.InteropServices.COMException

Ошибка возникает при формировании отчёта Word.

Возможные причины:

На Вашем компьютере установлена версия Microsoft 365.

Решение:

Убедитесь, что на Вашем компьютере установлена версия Microsoft Office, не имеющая ограничения
функциональности приложения Word, и повторите попытку.

Microsoft Office 2003 (Microsoft Office Word v.11)

такой код в в asp.net приложении

object template_file = "D:\samle.doc";
object miss = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application app = null;
Microsoft.Office.Interop.Word.Document doc_temp = null;
app = new Microsoft.Office.Interop.Word.Application();
app.Visible = false;
app.ScreenUpdating = false;
app.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
doc_temp = app.Application.Documents.Open(ref template_file, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);

...

в выделенной строке выбрасывается System.Runtime.InteropServices.COMException:

[COMException (0x800a1066): Ошибка команды]

НО! этот же код один-к-одному перенесенный в консольное .net приложение работает без ошибок.

Помогите решить проблему.

Здравствуйте, Аноним, Вы писали:

А>НО! этот же код один-к-одному перенесенный в консольное .net приложение работает без ошибок.


А>Помогите решить проблему.

Права пользователя.

M>Права пользователя.
несомненно:
чтобы протестировать в настройках DCOM для компонента «Приложение Microsoft Word» дал полные
права на все действия для пользователя Everyone. Не помогаеет

Здравствуйте, Аноним, Вы писали:

M>>Права пользователя.

А>несомненно:
А>чтобы протестировать в настройках DCOM для компонента «Приложение Microsoft Word» дал полные
А>права на все действия для пользователя Everyone. Не помогаеет

Шо, и на файл тоже?
Я бы посоветовал временно исполнить само web-приложение под правами… ну вашими, скажем. И посмотреть на результат.

А вообще — здесь

Понравилась статья? Поделить с друзьями:
  • Word system of equations
  • Word synonyms for however
  • Word synonym and antonym list
  • Word symphony что такое
  • Word symbols not printing