Use .NET COM in vb6

落花浮王杯 提交于 2019-12-23 12:50:03

问题


Im having trouble using a .NET COM in vb6, It compiles ok and I use regasm to register it, add a reference to it in the vb6 project, it even has intellisense. But when I try to make make an instance it gives me an 'Automation Error'. Any one can help?

Thanks in advance.


回答1:


You probably need to make sure your .NET assemblies are in the VB6 application's directory, or if debugging in the VB6 IDE that they are in the VB6.exe's directory.

It is possible to make COM interop with .NET assemblies work more like COM dlls (see the codebase option of regasm) but by default, .NET assemblies are searched for in the usual way - ie in the GAC or application directory - even when used via COM interop.

A really simple way to get insight into where your assembly should be is by using sysinternals filemon utility.




回答2:


I think you have to compile the .Net project in a certain way to be used by COM objects. And the .Net dlls need to be next to, in the same directory, as the COM object that calls them (If they occupy the same space I think).

Project Property Pages\Configuration Properties\Build\Register for COM Interop = true



来源:https://stackoverflow.com/questions/270613/use-net-com-in-vb6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!