COM互操作问题 [英] COM Interop Problem

查看:65
本文介绍了COM互操作问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个COM服务器,我根据书中的信息写了

..NET和COM /完整的Interop指南。我已经把这个项目编译成了b $ b编译,我找到了我想要运行的regasm.exe程序

对我的dll来生成一个TLB文件为了将COM对象导入其他编程语言(如Delphi)。


然而,当我尝试将类型库导入Delphi时我用其他组件完成了数百次
,我在

mscorlib_tlb文件中发现构建错误,该文件表明Type Byte未完全定义

以及字节的OLE自动化部分中的非法类型。


任何人都可以告诉我这里发生了什么以及如何解决它,因为书中说

没问题。


谢谢,

glenn

解决方案



" glenn" < GH ****** @ softeksoftware.com>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

我有我根据书中提供的信息编写的COM服务器
.NET和COM /完整的Interop指南。我已经得到了这个项目来编译,我已经找到了我想要运行的regasm.exe程序来对抗我的dll,以便为了
生成一个TLB文件将COM对象导入其他编程语言如Delphi。

然而,当我尝试将类型库导入Delphi时我已经完成了数百个与其他组件相关的时间,我在
mscorlib_tlb文件中出现构建错误,该文件表明类型字节未完全定义,以及字节的OLE自动化部分中的非法类型。
任何人都可以告诉我这里发生了什么以及如何解决这个问题

没问题。

谢谢,

glenn




您可以发布您的代码(或部分),以及regasm.exe命令行
使用
参数吗? br />
不确定mscorlib_tlb来自哪里,这是Delphi生成的类型库吗?

你试过cre吃了一个实例并从一个简单的方法调用一个方法

vb / Jscript?


Willy。


我没有尝试过Java,因为我不知道java。这是代码和它非常好的

直接从书中出来。


这本书告诉我运行regasmCom Server.dll / tlb其中Com Server只是

恰好是我命名为我的测试应用程序。正在生成tlb并在类型库中注册了
。在Delphi中,对于任何其他COM对象,我只需要从列表中选择对象,然后构建包装器并将其添加到

我要使用的组件托盘中。但是在这种情况下,由于这些错误,我无法将它包裹起来。


谢谢,


glenn

使用System;


使用System.Text.RegularExpressions;


使用System.Reflection ;


// [assembly :AssemblyKeyFile(" KeyFile.snk")]

命名空间COM_Server


{


///< summary>


///验证摘要说明。


///< / summary>


公共类验证


{


公共验证()


{


//


// TODO :在这里添加构造函数逻辑


//


}

public bool IsPhoneNumber(string s)


{


返回Regex.IsMatch(s,


@" ^(((\ (\d {3} \)()?)|(\d {3}(| \ - )))\\\ {3} \-\d {4})

");


}

public bool IsZipCode(string s)


{


返回Regex.IsMatch(s,@" ^((\d {5})|(\d {5} \-\d { 4}))

I have a COM Server that I''ve written based on information from the book
..NET and COM / the complete Interop Guide. I have gotten the project to
compile and I''ve located the regasm.exe program that I was suppose to run
against my dll in order to generate a TLB file for the purposes of importing
the COM object into other programming lanugages such as Delphi.

However, when I try to import the type library into Delphi which I have done
hundreds of times with other components, I get build errors in the
mscorlib_tlb file that states that the Type Byte is not completely defined
as well as Illegal type in OLE automation section for Byte.

Can anyone tell me what is happening here and how to fix it as the book says
nothing of the issue.

thanks,
glenn

解决方案


"glenn" <gh******@softeksoftware.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

I have a COM Server that I''ve written based on information from the book
.NET and COM / the complete Interop Guide. I have gotten the project to
compile and I''ve located the regasm.exe program that I was suppose to run
against my dll in order to generate a TLB file for the purposes of
importing
the COM object into other programming lanugages such as Delphi.

However, when I try to import the type library into Delphi which I have
done
hundreds of times with other components, I get build errors in the
mscorlib_tlb file that states that the Type Byte is not completely defined
as well as Illegal type in OLE automation section for Byte.

Can anyone tell me what is happening here and how to fix it as the book
says
nothing of the issue.

thanks,
glenn



Could you post your code (or part of), and the regasm.exe command line
arguments used?
Not sure where mscorlib_tlb comes from, is this a Delphi generated typelib?
Did you try to create an instance and call a method from a simple
vb/Jscript?

Willy.


I have not tried Java as I don''t know java. Here is the code and its pretty
much straight out of the book.

the book told me to run regasm "Com Server.dll" /tlb where Com Server just
happens to be what I named my test app. The tlb is being generated and
registered in the type library. In Delphi for any other COM object I just
go choose the object from the list and it builds the wrappers and adds it to
my component pallet to use. In this case however, I can not get it to wrap
the object due to these errors.

Thanks,

glenn
using System;

using System.Text.RegularExpressions;

using System.Reflection;

//[assembly:AssemblyKeyFile("KeyFile.snk")]

namespace COM_Server

{

/// <summary>

/// Summary description for validation.

/// </summary>

public class validation

{

public validation()

{

//

// TODO: Add constructor logic here

//

}
public bool IsPhoneNumber( string s )

{

return Regex.IsMatch(s,

@"^(((\(\d{3}\)( )?)|(\d{3}( |\-)))\d{3}\-\d{4})


");

}
public bool IsZipCode( string s )

{

return Regex.IsMatch(s, @"^((\d{5})|(\d{5}\-\d{4}))


这篇关于COM互操作问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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