问题描述
在VB.NET帮助文件演练:创建COM对象
with Visual Basic .NET中,它说:
"注意使用Visual生成的COM对象
Studio .NET不能被其他Visual Studio .NET
应用程序使用。尝试添加对此类COM
对象的引用会引发错误。
我的问题是:
如何编写一个COM对象,也可以用于
Visual Studio .NET应用程序?
In VB.NET help file "Walkthrough: Creating COM Objects
with Visual Basic .NET", It said:
"Note The COM objects you generate with Visual
Studio .NET cannot be used by other Visual Studio .NET
applications. Attempts to add references to such COM
objects raise an error."
My question is:
How to write a COM objects which can also be used by
Visual Studio .NET application?
推荐答案
您注意到上面的注释从未说明您无法直接引用该对象
,您只是可以将它作为COM对象引用。所以基本上这意味着
当你创建一个.NET COM对象时,你得到一个.TLB文件和一个.DLL或
..EXE。上面的注释只是说你不能在
..NET中使用_COM_对象,但普通程序集(.DLL)应该没问题。
这就是我理解它的方式,我可能错了,但这是否意味着
感觉?
~
Jeremy
You notice that the Note above never says you cant reference the object
directly, you just can reference it as a COM object. So basically this mean
that when you create a .NET COM object, you get a .TLB file and a .DLL or
..EXE. The note above is just saying that you can''t use the _COM_ object in
..NET, but the plain assembly (.DLL) should be fine.
This is the way I understood it, and I may be wrong, but does that make
sense?
~
Jeremy
HTH,
Herfried K. Wagner
-
MVP·VB Classic,VB .NET
"注意使用Visual生成的COM对象
Studio .NET不能使用通过其他Visual Studio .NET
应用程序。尝试添加对这样的COM
对象的引用会引发错误。
也许你可以在VB6中为.NET COM组件编写一个包装器组件
并在其他.NET项目中使用它...不是一个很好的建议,我知道了.b $ b。希望是更好的一个:你真的需要另一个.NET应用程序中的.NET-COM组件吗?为什么不直接使用托管.NET组件
,而不是通过它的COM包装器?
-
Armin
"Note The COM objects you generate with Visual
Studio .NET cannot be used by other Visual Studio .NET
applications. Attempts to add references to such COM
objects raise an error."
Maybe you could write a wrapper component in VB6 for your .NET COM component
and use it in the other .NET project... not really a good suggestion, I
know. Hopefully a better one: Do you really need a .NET-COM component in
another .NET application? Why don''t you use the managed .NET component
directly, not via it''s COM wrapper?
--
Armin
这篇关于如何编写COM组件......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!