如何诊断病因,修复,或解决的Adobe的ActiveX / COM相关的错误0x80004005 progmatically? [英] How to diagnose cause, fix, or work around Adobe ActiveX / COM related error 0x80004005 progmatically?

查看:450
本文介绍了如何诊断病因,修复,或解决的Adobe的ActiveX / COM相关的错误0x80004005 progmatically?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个C#.NET应用程序,使用的Adobe ActiveX控件来显示PDF。

它依赖于一对夫妇的DLL获得附带的应用程序。 这些DLL与本地安装Adobe Acrobat或Adobe Acrobat Reader软件安装在机器上。互动

此应用程序正在使用的一些客户已经和伟大工程的几乎所有用户(我检查本地计算机运行的是Acrobat或Reader已经至少9版)。

我已经找到3情况下,应用程序返回尝试加载(当ActiveX控件被加载)时,错误HRESULT E_FAIL已返回通过调用COM组件。

错误信息

我已经检查了这些用户的机器之一,他拥有的Acrobat 9安装,并经常使用它,没有任何问题。它似乎是的Acrobat 7和8分别安装在同一时间,因为有在注册表中为他们的条目以及使用Acrobat 9。

我不能重现此问题在本地,所以我不知道到底要往哪个方向走。

在堆栈跟踪顶部的错误信息:System.Runtime.InteropServices.COMException(0x80004005的):错误HRESULT E_FAIL已返回通过调用COM组件

有些研究这个错误表示这是​​一个注册表问题。

没有任何人有一个线索,如何解决或解决此问题,或者确定如何找到问题的核心根源在哪里?

该错误消息的全文是这样的:

  

System.Runtime.InteropServices.COMException(0x80004005的):错误HRESULT E_FAIL已返回通过调用COM组件。   在System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(GUID&安培; CLSID,对象punkOuter,的Int32背景下,的Guid和放大器; IID)   在System.Windows.Forms.AxHost.CreateWithoutLicense(GUID CLSID)   在System.Windows.Forms.AxHost.CreateWithLicense(字符串许可证中GUID CLSID)   在System.Windows.Forms.AxHost.CreateInstanceCore(GUID CLSID)   在System.Windows.Forms.AxHost.CreateInstance()   在System.Windows.Forms.AxHost.GetOcxCreate()   在System.Windows.Forms.AxHost.TransitionUpTo(的Int32州)   在System.Windows.Forms.AxHost.CreateHandle()   在System.Windows.Forms.Control.CreateControl(布尔fIgnoreVisible)   在System.Windows.Forms.Control.CreateControl(布尔fIgnoreVisible)   在System.Windows.Forms.AxHost.EndInit()   在AcrobatChecker.Viewer.InitializeComponent()   在AcrobatChecker.Viewer..ctor()   在AcrobatChecker.Form1.btnViewer_Click(对象发件人,EventArgs的)   在System.Windows.Forms.Control.OnClick(EventArgs的五)   在System.Windows.Forms.Button.OnClick(EventArgs的五)   在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)   在System.Windows.Forms.Control.WmMouseUp(消息和,男,MouseButtons按钮,点击的Int32)   在System.Windows.Forms.Control.WndProc(消息&安培;米)   在System.Windows.Forms.ButtonBase.WndProc(消息&安培;米)   在System.Windows.Forms.Button.WndProc(消息&安培;米)   在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息&安培;米)   在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息&安培;米)   在System.Windows.Forms.NativeWindow.Callback(IntPtr的的HWND,味精的Int32,IntPtr的WPARAM,IntPtr的LPARAM)

解决方案

好了,报告给回答我的问题。

这个问题直接关系到设置在preferences显示PDF浏览器>互联网。 选中该选项时,问题消失。当它被选中,它回来了。

下面是我们提出以编程方式处理它:

 私人字符串defaultPdfProg()
    {//返回的默认程序打开.pdf文件;在失败返回空字符串。
      //(见下面的注意事项)
        字符串RETVAL =;

        的RegistryKey pdfDefault = Registry.ClassesRoot.OpenSubKey(PDF)OpenSubKey(OpenWithList)。
        字符串[] progs的= pdfDefault.GetSubKeyNames();
        如果(progs.Length大于0)
        {
            RETVAL = progs的[1];
            字符串[] =件retval.Split('。'); //删除.EXE

            如果(pieces.Length大于0)
            {
                RETVAL =件[0];
            }
        }

        返回RETVAL;
    }

    私人无效browserIntegration(字符串defaultPdfProgram)
    {//测试是否启用浏览器集成安装Adobe Acrobat(见下面的注意事项)
        的RegistryKey读卡器= NULL;
        字符串[] VERS = NULL;

        如果(defaultPdfProgram.ToLower()==杂技演员)
        {//默认的程序是使用Adobe Acrobat
            读卡器= Registry.LocalMachine.OpenSubKey(软件)OpenSubKey(Adobe)的OpenSubKey(使用Adobe Acrobat)。
            VERS = reader.GetSubKeyNames();
        }
        否则,如果(defaultPdfProgram.ToLower()==acrord32)
        {//默认程序是Adobe Acrobat Reader软件
            读卡器= Registry.LocalMachine.OpenSubKey(软件)OpenSubKey(Adobe)的OpenSubKey(Acrobat Reader软件)。;
            VERS = reader.GetSubKeyNames();
        }
        其他
        {
            // TODO:处理非 - 土坯.PDF默认程序
        }

        如果(vers.Length大于0)
        {
            字符串versNum = VERS [vers.Length  -  1]的ToString();
            读卡器= reader.OpenSubKey(versNum);
            读卡器= reader.OpenSubKey(AdobeViewer,真正的);

            布尔keyExists = FALSE;
            双的keyValue = -1;
            的foreach(在reader.GetValueNames串adobeViewerValue())
            {
                如果(adobeViewerValue.Contains(BrowserIntegration))
                {
                    keyExists = TRUE;
                    的keyValue = Double.Parse(reader.GetValue(BrowserIntegration)的ToString());
                }
            }

            如果(keyExists == ||假keyValue的< 1)
            {
                字符串消息=此应用程序需要在Adobe的设置来改变你愿意尝试自动更改此设置。?;
                DialogResult的createKey =的MessageBox.show(消息,为Adobe设置,MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);
                如果(createKey.ToString()==行)
                {
                    reader.SetValue(BrowserIntegration,1,RegistryValueKind.DWord);
                    //测试,以确保注册表值设为
                }
                如果(createKey.ToString()==取消)
                {
                    // TODO:提供的说明手动更改设置
                }
            }
        }
    }
 

几个项目要注意的:

  • 这似乎根据这两篇文章中,密钥可以在注册表(原件VS Adob​​eViewer)两个不同的位置: <一href="http://support.adobe.com/devsup/devsup.nsf/docs/51722.htm">http://support.adobe.com/devsup/devsup.nsf/docs/51722.htm http://support.adobe.com/devsup/devsup.nsf/docs/53556.htm

有谁知道,如果基于Acrobat中的特定版本的注册表项是在不同的地点,这些地点是可以互换的所有版本,或者?读者是否遵循同样的逻辑的Acrobat?

  • 在Adobe是否使用任何其他方法来确定'默认的Adobe应用程序打开PDF文件的其他比windows文件关联?我问,因为如果你有一个非Adobe的产品,如福昕安装为默认文件关联的应用程序,但使用的是安装了这两个Reader和Acrobat的ActiveX控件的Adobe一台机器上,什么逻辑来决定哪些应用程序COM对象会跟?

I've built a C# .NET app that uses the Adobe ActiveX control to display a PDF.

It relies on a couple DLLs that get shipped with the application. These DLLs interact with the locally installed Adobe Acrobat or Adobe Acrobat Reader installed on the machine.

This app is being used by some customer already and works great for nearly all users ( I check to see that the local machine is running at least version 9 of either Acrobat or Reader already ).

I've found 3 cases where the app returns the error message "Error HRESULT E_FAIL has been returned from a call to a COM component" when trying to load (when the activex control is loading).

I've checked one of these user's machines and he has Acrobat 9 installed and is using it frequently with no problems. It does appear that Acrobat 7 and 8 were installed at one time since there are entries for them in the registry along with Acrobat 9.

I can't reproduce this problem locally, so I am not sure exactly which direction to go.

The error at the top of the stacktrace is: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

Some research into this error indicates it is a registry problem.

Does anyone have a clue as to how to fix or work around this problem, or determine how to get to the core root of the problem?

The full content of the error message is this:

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.    at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)    at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)    at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)    at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)    at System.Windows.Forms.AxHost.CreateInstance()    at System.Windows.Forms.AxHost.GetOcxCreate()    at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)    at System.Windows.Forms.AxHost.CreateHandle()    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)    at System.Windows.Forms.AxHost.EndInit()    at AcrobatChecker.Viewer.InitializeComponent()    at AcrobatChecker.Viewer..ctor()    at AcrobatChecker.Form1.btnViewer_Click(Object sender, EventArgs e)    at System.Windows.Forms.Control.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnClick(EventArgs e)    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)    at System.Windows.Forms.Control.WndProc(Message& m)    at System.Windows.Forms.ButtonBase.WndProc(Message& m)    at System.Windows.Forms.Button.WndProc(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

解决方案

Ok, reporting back to answer my own question.

The problem was directly related to the setting for 'Display PDF in browser' in Preferences > Internet. With this option checked, the problem goes away. When it is unchecked, it comes back.

Here is how we propose to handle it programmatically:

    private string defaultPdfProg()
    { //Returns the default program for opening a .pdf file; On Fail returns empty string. 
      // (see notes below) 
        string retval = "";

        RegistryKey pdfDefault = Registry.ClassesRoot.OpenSubKey(".pdf").OpenSubKey("OpenWithList");
        string[] progs = pdfDefault.GetSubKeyNames();
        if (progs.Length > 0)
        {
            retval = progs[1];
            string[] pieces = retval.Split('.'); // Remove .exe

            if (pieces.Length > 0)
            {
                retval = pieces[0];
            }
        }

        return retval;
    }

    private void browserIntegration(string defaultPdfProgram)
    { //Test if browser integration is enabled for Adobe Acrobat (see notes below)
        RegistryKey reader = null;
        string[] vers = null;

        if (defaultPdfProgram.ToLower() == "acrobat")
        { //Default program is Adobe Acrobat
            reader = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe").OpenSubKey("Adobe Acrobat");
            vers = reader.GetSubKeyNames();
        }
        else if (defaultPdfProgram.ToLower() == "acrord32")
        { //Default program is Adobe Acrobat Reader
            reader = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe").OpenSubKey("Acrobat Reader");
            vers = reader.GetSubKeyNames();
        }
        else
        {
            //TODO: Handle non - adobe .pdf default program
        }

        if (vers.Length > 0)
        {
            string versNum = vers[vers.Length - 1].ToString();
            reader = reader.OpenSubKey(versNum);
            reader = reader.OpenSubKey("AdobeViewer",true);

            Boolean keyExists = false;
            Double keyValue = -1;
            foreach(string adobeViewerValue in reader.GetValueNames())
            {
                if (adobeViewerValue.Contains("BrowserIntegration"))
                {
                    keyExists = true;
                    keyValue = Double.Parse(reader.GetValue("BrowserIntegration").ToString());
                }
            }

            if (keyExists == false || keyValue < 1)
            {
                string message = "This application requires a setting in Adobe to be changed. Would you like to attempt to change this setting automatically?";
                DialogResult createKey = MessageBox.Show(message, "Adobe Settings", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (createKey.ToString() == "OK")
                {
                    reader.SetValue("BrowserIntegration", 1, RegistryValueKind.DWord);
                    //test to make sure registry value was set
                }
                if (createKey.ToString() == "Cancel")
                {
                    //TODO: Provide instructions to manually change setting
                }
            }
        }
    }

A few items to note:

Does anyone know if these locations are interchangeable in all versions or if based on specific versions of Acrobat the registry key is in different locations? Does Reader follow the same logic as Acrobat?

  • Does Adobe use any other method to determine the 'default Adobe application for opening PDF files' other than the windows file association? I ask because if you have a non-adobe product, such as FoxIt installed as the default file association application, but are using the ActiveX control for Adobe on a machine that has both Reader and Acrobat installed, what logic is used to decide which application the COM object will talk to?

这篇关于如何诊断病因,修复,或解决的Adobe的ActiveX / COM相关的错误0x80004005 progmatically?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆