将C#组件导出到COM并使用它们 [英] Exporting C# components to COM and using them

查看:101
本文介绍了将C#组件导出到COM并使用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个COM问题(Bob不再帮我了)。



这次我通过COM注册了ac #dll(让我们称之为MyCSharpComponent .dll)引用另一个dll(MyKernel.dll)

MyKernel.dll几乎没有MyCSharpComponent.dll使用的基本类。它们主要代表颜色,边框颜色和某些元素之类的东西。



Hello, I have a problem with COM (Bob help me not again).

This time I have a c# dll registered though COM(lets Call it MyCSharpComponent.dll) which has a reference to another dll(MyKernel.dll)
The MyKernel.dll has few basic classes used by the MyCSharpComponent.dll. They mainly represent color, border color and stuff like that of some element.

[ComVisible(true)]
[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ICSharpComponentControlEvents
{
}

//definition of the interface
[ComVisible(true)]
[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ICSharpComponentControl
{
}

//definition of the class
[ClassInterface(ClassInterfaceType.None)]
[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
[ProgId("<The progId goes here>")]
[ComVisible(true)]
[ComSourceInterfaces(typeof(ICSharpComponentControlEvents))]
public partial class CSharpComponentControl:  ICSharpComponentControl
{
}







MyCSharpComponent.dll已通过Re注册使用以下命令行:




The MyCSharpComponent.dll is registered though RegAsm with following command line:

...\RegAsm.exe MyCSharpComponent.dll /codebase /tlb





我检查了Ole查看器,确实存在组件。



我用vc ++编写的应用程序调用注册的MyCSharpComponent.dll 。

当我使用同一文件夹中存在的两个dll启动应用程序时,一切都很好。

但如果我单独启动vc ++应用程序而没有MyCSharpComponent.dll或MyKernel .dll在这些类的这些变量所在的位置的文件夹中我得到了带有命名空间字符串的禁用元素,包括当前类的名称。



依据我的老板COM应该将这些类从引用的MyKernel.dll添加到MyCSharpComponent.dll的.tlb文件中,并且vc ++应用程序应该能够使用它们,而文件夹中没有dll并且没有为MyKernel.dll注册COM,但是我从来没有找到任何东西g支持他的理论,他让我独自处理它(数字)。



如果有人有想法我应该做什么,请随时写下来。

任何帮助将不胜感激。

提前谢谢。



注意:所有guid和名称都被更改。



I checked the Ole viewer and indeed the component are present.

I have application written in vc++ calling that registered MyCSharpComponent.dll.
Everything is good when i start the application with the two dlls present in the same folder.
But if I start the vc++ application alone with no MyCSharpComponent.dll or MyKernel.dll in the folder in the place where these variables of these classes should be I get disabled element with namespace string for value including the name of the current class.

According my boss COM should add these classes from the referenced MyKernel.dll to the .tlb file of MyCSharpComponent.dll and the vc++ application should be able to use them without the dll present in the folder and with no COM registration for MyKernel.dll, but i never found anything supporting his theory and he left me alone to deal with it (Figures).

If anyone has ideas what should I do, feel free to write it down.
Any help will be appreciated.
Thank you in advance.

Note:All guids and names are changed .

推荐答案

这篇关于将C#组件导出到COM并使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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