灾难性故障(来自HRESULT的异常:0x8000FFFF(E_UNEXPECTED)):ActiveX和C#控制台应用程序 [英] Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)): ActiveX and C# Console Application

查看:3850
本文介绍了灾难性故障(来自HRESULT的异常:0x8000FFFF(E_UNEXPECTED)):ActiveX和C#控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在玩的ActiveX和C#和如何两者可以一起工作的方式。事情是我打开了墙的权利在开头提到的错误。我遵循的步骤:

So, I am playing around with ActiveX and C# and ways how both of them can work together. the thing is I have hit the wall right in the beginning with mentioned error. Steps I have followed:

在VS2010中,我选择了MFC ActiveX Control项目。然后我添加了一个方法SHORT Multiply(SHORT a,SHORT b);通过单击在右键单击解决方案资源管理器中的ProjectnameLib下的_DProjectname时弹出的菜单中的添加方法选项。该方法的代码如下:

In VS2010 I selected MFC ActiveX Control project. Then I added a method "SHORT Multiply( SHORT a, SHORT b);" by clicking the Add method option in the menu that pops when you right click _DProjectname under ProjectnameLib in solution explorer. The code for the method is as follows:

    SHORT CSampleProgramActivex01Ctrl::Multiply(SHORT a, SHORT b)
    {
      AFX_MANAGE_STATE(AfxGetStaticModuleState());

     // TODO: Add your dispatch handler code here

     return ( a * b);
    }


$ b $ p现在我创建了一个简单的C#控制台应用程序,引用生成的COM文件,当我尝试使用该方法,应用程序停止与上述错误。我在互联网上搜索错误,但没有提到清晰的解决方案。任何帮助赞赏。如果你们想要澄清,让我知道。

Now I have created a simple C# console application that references the generated COM file and when I try to use the method, the application stops with the above mentioned error. I have searched the error on the internet but no clear solution is mentioned. Any help appreciated. If you guys want clarification, let me know.

推荐答案

我不知道这是否被视为解决问题但我发现了一个解决方法:

I don't know whether this is considered as solving the problem or not but I found a workaround:

第一次,而不是C#控制台应用程序,我创建了C#窗口窗体应用程序。创建表单后,我将整个ocx作为组件添加到工具箱中。您可以通过右键单击工具箱菜单中的工具箱类型来实现。在新菜单中,单击选择项目。这弹出新的菜单,在选择COM选项卡,在该检查您的COM组件和COM组件将被添加到工具箱菜单。现在拖放菜单上的组件,你应该很好去。

First instead of C# console application, I created C# windows form application. After creating the form, I have added the whole ocx as component in the toolbox. You do this by right-clicking the Toolbox types in Toolbox menu. In the new menu, you click Choose Items. This pops up new menu and in that select the COM tab and in that check your COM component and the COM component will be added to the Toolbox menu. Now drag and drop the component on the menu and you should be good to go.

这似乎是每个人都关注的解决方法。不整洁,但这是我认为的规范。

This seems to be workaround that everybody is following. Not neat but that is the norm I think.

这篇关于灾难性故障(来自HRESULT的异常:0x8000FFFF(E_UNEXPECTED)):ActiveX和C#控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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