HOWTO:使用远程COM +对象 [英] HOWTO: using a remote COM+ object

查看:90
本文介绍了HOWTO:使用远程COM +对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用另一个IDE(SQLWindows/Unify),我创建了一个包含一些业务逻辑的COM对象.现在,我想使用VS2010和C#访问此COM对象的方法.我的COM对象有.dll和.tlb文件.

using another IDE (SQLWindows/Unify) I created a COM-object containing some business logic. Now I want to access the methods of this COM-object using VS2010 and C#. I have the .dll and .tlb file for my COM object.

在我的第一次尝试中,我使用regsvr32在本地注册了DLL.我从C#客户端引用了DLL,并且可以成功调用此COM对象中的方法.

In my first try, I registered the DLL locally using regsvr32. I referenced the DLL from my C# client and can successfully call the methods in this COM object.

现在,我想使用组件服务在远程计算机上安装此COM对象.我知道如何进行远程安装.我不知道如何使用C#客户端访问远程COM对象.到目前为止,我发现必须创建一个新的 使用tlbimp.exe的.tlb文件中的DLL.在我的远程com对象的C#客户端中,我需要引用此新DLL.但是,如何创建/激活远程com对象以调用任何方法?我必须以某种方式指定服务器名称或IP地址.我发现 一些有关如何使用反射调用远程com对象的代码,但是该线程说,这仅在没有.tlb时才有意义

Now I want to install this COM object on a remote machine using the Component service. I know how to do the remote install. What I don't know is how to access the remote COM object with my C# client. From what I've found so far is, that I must create a new DLL from the .tlb file using tlbimp.exe. In my C# client for the remote com object  I need to reference this new DLL. But how do I create/activate the remote com object to call any method? Somehow I must specify the servers name or IP address. I found some code about how to call a remote com object using reflection but this thread says that this is only relevant when you don't have the .tlb

当我假设只要我的COM对象的接口不变时,我就可以在服务器上安装新版本,并且远程客户端仍可以使用通过tlbimp创建的旧DLL正常工作.还是我必须重新创建此DLL 每次都与tlbimp在一起吗?

Am I right when I assume that as long as the interface of my COM object does not change, that I can install a new version on the server and the remote client will still work with the old DLL created with tlbimp. Or must I recreate this DLL with tlbimp every time?

如果有人可以将我指向某些文档,或者甚至只是展示如何创建和访问远程对象,甚至给我一些小的代码,我都会很高兴.

I would be glad if someone can point me to some document or even give me some small peace of code just showing how to create and access the remote object.

谢谢,
Stefan

Thanks,
Stefan

推荐答案

我们有一个COM +服务器,可以在C#应用程序中成功使用它.由于它是使用VB6创建的,因此创建VBR只需选中一个复选框即可.

We have a COM+ server and succesfully use it from C# applications. Since it was created with VB6, the creation of a VBR is just a matter of checking a checkbox.

然后使用类似于以下内容的行注册远程dll:

You then register the remote dll with a line similar to:

clireg32 -s 192.168.181.2 -d -q NameOfDll.VBR

 clireg32 -s 192.168.181.2 -d -q NameOfDll.VBR

如果您不使用VB,则生成vbr看起来会有些复杂: http://support.microsoft.com/kb/184696

If you're not using VB, it looks like it's a bit more complicated generating a vbr: http://support.microsoft.com/kb/184696


这篇关于HOWTO:使用远程COM +对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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