问题标签 [comexception]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
449 浏览

c# - 通过 WMI 查询时防止 ComExceptions

我有一些代码使用 WMI 搜索 Windows 域以查找符合某些条件的计算机。

如果我无法与我尝试查询的计算机通信,我会收到 COMException。在大型域上进行测试时,这可能会导致抛出数千个异常,这在性能方面非常昂贵。

有没有办法让我在查询之前检查有效连接,以便防止这些错误发生?

简化示例:

0 投票
0 回答
1570 浏览

c# - COMException 在某些 2008 R2 环境中使用 WebBrowser 控件

在某些 2008 R2 环境而不是其他环境中,我COMExceptions在使用System.Windows.Forms.WebBrowser控件时遇到了问题。无论是通过DocumentText属性指定内容还是Navigate使用 URL 参数调用方法,我都会遇到相同的异常:

COMException - 对 COM 组件的调用已返回错误 HRESULT E_FAIL。

System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Refresh()

我发现在指定之前设置ScrollBarsEnabled属性会导致此异常,这似乎是在浏览器没有内容时调用该方法(上面引用的)的结果(此处的最后一篇文章)。解决方法是设置一些模拟内容并调用. 但即使有了这个,它在稍后加载内容时会导致上述异常(在另一个线程中完成)。WebBrowserDocumentTextRefreshApplication.DoEvents()

请注意,DocumentCompleted我指定的委托正在被击中,但它WebBrowser.axIWebBrowser2.StatusText表明发生了异常,并且WebBrowser.Document为空。

我可以建立一个简单的应用程序来重现该问题,但我必须找到一个 2008 R2 实例,在该实例中该错误是可重现的,以便进行调试。我更多地询问是否有人知道可能会影响或导致问题的原因,可能与 COM 安全等有关。

请注意,我正在执行WebBrowser状态STA Apartment

任何想法或建议将不胜感激。提前致谢!-最大限度

0 投票
1 回答
1574 浏览

sharepoint-2010 - 从文档库 SharePoint 2010 读取数据时出现 401 未经授权的异常

我们开发了一个 WebPart 来读取 SiteCollection 中文档库中文件的内容。我使用以下代码来阅读内容。

但是,我收到以下错误 401 未经授权的异常

供您参考,我已经尝试通过 SPFile openBinary 方法下载文档。但它只适用于文档较小的情况。请参考以下网站。

在 SharePoint 2010 中阅读文档时出现 ComException

提前致谢。

0 投票
3 回答
714 浏览

c# - How to check ErrorCode for REGDB_E_CLASSNOTREG?

I would like to check if com exception is thrown due to REGDB_E_CLASSNOTREG then handle it. I tried with the code above but it gives warning:

I believe this error is due to 0x80040154 is not in Int32 range.

Can you suggest any possible solution? or Is there any other way to check this?

0 投票
1 回答
222 浏览

c# - 在 c# 中实现 IShellUIHelper 时,AddFavorite 不起作用

我正在构建一个 IE 插件,我想“成为”外部对象。因此我使用 SetUIHandler 将我的类设置为 UIHandler。

我正在实现 IDocHostUIHandler(引用 Microsoft Internet 控件(COM 对象))并在 GetExternal 中返回我的类:

这很好用。任何其他选项我都不感兴趣,所以我需要返回 E_NOTIMPL。

例如:

效果很好,但我还需要实现 IShellUIHelper(IE 期望它来自 UIHandler)。

然后当我实现添加到收藏夹时:

它不起作用(js得到了错误)。

当我尝试在 C++ 中做同样的事情并将 E_NOTIMPL 作为返回值返回时,一切都很好:

我也尝试用替换Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);throw new COMException("", (int)WinAPI.HRESULT.E_NOTIMPL);,它仍然不起作用。

任何人都可以帮助我吗?

谢谢,

暗里

0 投票
2 回答
5437 浏览

c# - 使用 Interop.MODI 引发 0x80040154 异常

我目前正在尝试实现 Interop.MODI.dll(来自 Microsoft Office)以使用它应该提供的 Image -> Text 功能。但是做的时候

我得到:

“带有 CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} 的 COMException 80040154”。

我尝试过什么来解决这个问题?

我使用 regasm 工具注册了 DLL:-问题仍然存在

我尝试将 BuildPlatform 设置为 x86:-问题仍然存在

我使用带有 Windows 7 Professional 64Bit 的 Visual Studio 2010 Ultimate 并安装了 Microsoft Office 2007

编辑:我找到了解决方案:

我需要将“MS-Office-Document-Imaging”功能安装到 MS Office 以使其正常工作。(软件 -> MS Office(右键单击 -> 编辑)-> 添加功能 -> Microsoft Office Document Imaging)

0 投票
1 回答
14813 浏览

asp.net - ASP.NET 4.0 Web App throwing "Incorrect function. (Exception from HRESULT: 0x80070001)"

The application is written in ASP .NET 4.0 hosted in IIS 7.5 on machine running Windows Server 2008 R2. The application pool is using Integrated Managed Pipline Mode.

The exception below is thrown when on several different pages which don’t have anything obvious in common. I can’t reproduce the exception myself, but it happened 10 times last week in the production environment.

From the Stack Trace I see that the exception thrown by the method "HttpRequest.GetEntireRawContent" so I was wondering if there is something wrong with request, such as it being too long or containing an invalid character.

Just to be clear, this exception is not thrown from code that I have written, it is from within the System.Web namespace. So I cannot add a try...catch around it.

I'd be greatful for any ideas on cause of the exception or troubleshooting steps to find out more information.

EDIT:

As pointed out by lukiffer there is a similiar question here: stackoverflow.com/questions/7825127/ The suggested fix is to turn off TCP offloading, the way I understand it is that TCP offloading shields the webserver from a lot of the complexity of TCP. Therefore turning it off would consume a lot of CPU cycles so slow down the web servers, which is obviously not desirable.

I also don't understand why TCP offloading would cause IIS to throw an exception.

0 投票
1 回答
131 浏览

excel - range.Formula 用极长的公式抛出 COMException

因此,您可以通过以下方式重现此问题:

1)打开两个工作簿(称它们为 wb1 和 wb2)

2) 在 wb1 中创建一个公式,引用另一个中的单元格,并确保在达到最大字符限制之前尽可能多地挤入单元格引用(即,您可以执行 "=sum([wb2.xlsx] Sheet1!A1,...,...,[wb2.xlsx]Sheet1!A1)"

3) 关闭 wb2,所以现在它的路径被附加到 wb1 公式中。然而,由于我们已经达到了极限,它推高了公式。

现在,如果我尝试访问单元格的公式属性,则会抛出 COMException。有什么解决方法吗?

0 投票
1 回答
403 浏览

c# - WPF应用程序主线程上的COMException

WPF、Excel AddIn、C#,我有多个异步调用来从主线程上的 Web 服务获取数据,然后在回调中,我将在 Excel 中绘制数据。我跟踪了回调,它们也在主线程上运行。但我仍然得到 COMException 0x800AC472,谷歌搜索,这似乎是一个多线程问题。

但我很困惑为什么会这样。我认为只有一个主线程,因为所有回调都在主线程上运行,没有理由有例外?

编辑:在主 UI 线程上,单击功能区/按钮,它将调用 Web 服务 BuildMetaData,一旦返回,在其回调 MetaDataCompleteCallback 中,发送另一个 Web 服务调用一旦返回,在其回调 DataRequestJobFinished 中,它将调用 plot 在 Excel 上绘制数据。见下文

在类上生成报告

0 投票
1 回答
1697 浏览

dll - 检索具有 CLSID 的组件的 COM 类工厂 - 80040154

我有一个带有 2 个类型库并使用 Visual Studio 2008 开发 PC(XP SP2 32 位)的第 3 方组件“ArchesrA.MxAccess.dll”(由 corgflags 在 x86 上构建)。

当我在代码中创建类的实例时,它会抛出 COMException - 80040154。

以下我尝试过的解决方案:

  1. RegSVR32 DLL,但无法注册。作为“找不到入口点”。

  2. Regtlib 类型库,成功

  3. regasm DLL,成功。

  4. 编译器模式在 x86 上。

  5. 错误的 CLSID 在注册表中有条目:HKCR\CLSID\ 并指向此 DLL。

请帮忙。我从 3 天开始就在寻找解决方案。

开发。


regasm with codebase 使用 codebase 进入并指向文件名,它是成功的。也用GACUtill注册了dll,成功了。

但同样的错误即将到来。

我的 ProcMon 找不到条目

和一样

只有可用条目是

运行时版本 = V1.1.4322

这是否意味着我需要安装 1.1 框架?