无法创建组件“AxHost" System.Runtime.InteropServices.COMException (0x80029C4A) [英] Failed to create component 'AxHost' System.Runtime.InteropServices.COMException (0x80029C4A)

查看:33
本文介绍了无法创建组件“AxHost" System.Runtime.InteropServices.COMException (0x80029C4A)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 中创建了 .Net 用户控件.它是带有文本框和列表框的图形控件.现在我想在旧版 VC++ 应用程序中使用这个控件.(本机二进制).意味着我想从非管理代码调用管理代码.

I have created .Net usercontrol in C#. it is graphical control with a text box and listbox. Now I want to use this control in legacy VC++ application.(native binary). means I want to call manage code from unmanage code.

假设我的用户控件名称是 xyz.dll.我使用 tlbexp.exe 生成了 tlb 文件,然后我使用下面的命令行注册了这个控件.regasm xyz.dll/tlb:"C:\xyz.tlb"/codebase

suppose my usercontrol name is xyz.dll. I generated tlb file using tlbexp.exe and then i registered this control using below command line. regasm xyz.dll /tlb:"C:\xyz.tlb" /codebase

我已经使用Activex 控件测试容器"检查了我的控件(打开 studio 2005 并转到工具"菜单)我在这个工具上测试了我的 .Net 用户控件,它运行良好.

I have checked my control using 'Activex control test container' (open studio 2005 and go to 'tools' menu) I tested my .Net usercontrol on this tool and it worked fine.

然后我创建了一个示例 C# 窗口应用程序.在工具箱下,我右键单击并选择选择项目"并选择COM 组件"选项卡.并选择我的 xyz.dll 控件.现在此控件已添加到工具箱中.

then I created a sample C# window application. Under Toolbox, I right click and selected 'Choose Items' and selected "COM component" tab. and choose my xyz.dll control. now this contol is added into toolbox.

但是当我将此控件拖到窗口上时,出现以下错误.未能创建组件AxHost".错误信息如下:

But when I drag this control onto window then i got below error. Failed to create component 'AxHost'. The error message follows:

'System.Runtime.InteropServices.COMException (0x80029C4A):加载类型库/DLL 时出错.(来自 HRESULT 的异常:0x80029C4A (TYPE_E_CANTLOADLIBRARY))在 System.Windows.Forms.Design.DocumentDesigner.AxToolboxItem.CreateComponentsCore(IDesignerHost 主机)在 System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost 主机,IDictionary defaultValues)在 System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost 主机,IDictionary defaultValues)在 System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)'.

'System.Runtime.InteropServices.COMException (0x80029C4A): Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)) at System.Windows.Forms.Design.DocumentDesigner.AxToolboxItem.CreateComponentsCore(IDesignerHost host) at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host, IDictionary defaultValues) at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)' .

还给我一些指示如何将 .net usercontrol 用于遗留 C# 应用程序"

also give me some pointer "how to use .net usercontrol into legacy C# application"

推荐答案

目前没有足够的信息,但我的猜测是:

There is not enough information but my guess so far:

控件是在 .NET 4 中开发的,而传统的 C# 应用程序是在 .NET 2 中..NET 4 可以在同一进程中混合 .NET 版本,但 .NET 2 不能,所以我怀疑要解决这个问题,您需要在 .NET 2 中开发/构建控件,以便它可以在 .NET 2 & 中使用.4.

The Control is developed in .NET 4 and the legacy C# application is in .NET 2. .NET 4 can mix .NET-version in the same process, but .NET 2 can't so I suspect to solve this you need to develop/build the control in .NET 2 so that it is usable in .NET 2 & 4.

编辑(在关于 .NET 3.5 的评论之后):

EDIT (after the comment about .NET 3.5):

您需要通过运行 regsvr32 来注册控件.

You need to register the control by running regsvr32.

编辑 2:
regsvr32 xyz.dllregsvr32/i xyz.dll

这篇关于无法创建组件“AxHost" System.Runtime.InteropServices.COMException (0x80029C4A)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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