简体   繁体   English

从VB调用.Net类库(dll)

[英]Calling .Net Class Library (dll) from VB

I've used a tutorial ( http://support.microsoft.com/kb/317535 ) to create a VB.NET Class that exports a COM visible method for calculating MD5 checksums. 我使用了一个教程( http://support.microsoft.com/kb/317535 )创建一个VB.NET类,该类导出一个COM可见方法来计算MD5校验和。

The problem is that I need to call this .dll from a language similar to VB (Extra Basic) and it only supports COM calls. 问题是我需要从类似于VB(额外基本版)的语言调用此.dll,并且它仅支持COM调用。 On my machine everything works like a charm, but on the destination server it doesn't work at all. 在我的机器上,所有内容都像超级按钮一样工作,但在目标服务器上却根本不起作用。 I get "Object creation failed" from the "VB like" application. 我从“ VB类”应用程序中获得“对象创建失败”。

According to the tutorial the only thing one need to do is to use regasm to register the .dll. 根据教程,唯一要做的就是使用regasm注册.dll。 This doesn't work. 这行不通。 I have obviously made something wrong when I registered the .dll. 当我注册.dll时,我显然做错了。

What do VS2005 do to make this .dll visible for COM calls? VS2005做什么使该.dll对于COM调用可见?

I have tried to uese regsvr32, but it faild to register the .dll with the following message: "xxx.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered" 我尝试使用regsvr32,但无法使用以下消息注册.dll:“已加载xxx.dll,但未找到DllRegisterServer入口点。无法注册此文件”

Best regards Ausgar 最好的问候奥斯加尔

You can't use Regsvr32.exe, Regasm.exe is required. 您不能使用Regsvr32.exe,需要Regasm.exe。 You must either run it with the /codebase command line argument or install the assembly in the GAC. 您必须使用/ codebase命令行参数运行它,或在GAC中安装程序集。 I assume that's your problem. 我认为那是你的问题。

These kind of registration issues are always fugly, not in the least because they require an install program instead of Xcopy.exe. 这些注册问题总是很丑陋,至少不是因为它们需要安装程序而不是Xcopy.exe。 And invoke DLL Hell if you don't version correctly. 如果版本不正确,则调用DLL Hell。 Which you won't if you don't use the GAC. 如果您不使用GAC,则不会。 Consider using a manifest instead that contains the <clrClass> element. 考虑使用包含<clrClass>元素的清单来代替。 Take the first Google hit. 抢先击中Google。

Have you tried registering the COM DLL using regsvr32 ? 您是否尝试过使用regsvr32注册COM DLL? I don't know if regasm does this automatically but apparently it doesn't. 我不知道,如果regasm自动执行此操作,但显然事实并非如此。

It sounds like you don't have all the items that your application requires installed or working on the server. 听起来您没有在服务器上安装或运行应用程序所需的所有项目。 Some things to look at are: 需要注意的一些事情是:

  1. Is the .NET Framework installed? 是否安装了.NET Framework?
  2. Make sure COM is working. 确保COM正在运行。 Some fundamental things to try are: 一些基本的尝试:
    • Inserting an object in a WordPad document. 在写字板文档中插入对象。
    • If you can run WSCript, run a simple vbscript that creates an object. 如果可以运行WSCript,请运行创建对象的简单vbscript。
    • Run Dependency Walker on your EXE and make sure you have everything you need. 在EXE上运行Dependency Walker ,并确保拥有所需的一切。
  3. If the above doesn't get you going you can use Sysinternals ProcMon to watch what files and registry entries your application is accessing (and maybe not finding). 如果以上方法仍然无法解决问题 ,则可以使用Sysinternals ProcMon来监视您的应用程序正在访问(也许找不到)的文件和注册表项。 This should give you clues as to what is going on. 这应该为您提供正在发生的事情的线索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM