VB6对COM可调用包装的.NET - 问题,找到.NET库 [英] VB6 to COM-callable wrapped .NET - problems finding .NET libraries

查看:229
本文介绍了VB6对COM可调用包装的.NET - 问题,找到.NET库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

premise:

  • 在写C#编写的一个COM,调用包装(CCW)由VB6 code调用。
  • 的C#code有.NET库(第三方),它必须使用。
  • 的包裹C#类实例化精,妥善引发事件,采取的方法调用正常。
  • Wrote a COM-callable wrapper (CCW) written in C# to be called by VB6 code.
  • The C# code has .NET libraries (third party) that it must utilize.
  • The wrapped C# class instantiates fine, raises events properly, takes method calls properly.

问题:

  • 在VB6的code,运行C#code时,得到当C#code尝试访问额外的.NET库上面提到的错误。

流程进行测试:

  • 在C#裹code完成。
  • 在VB6 code写的,引用创建的COM DLL。
  • 在找不到文件......当C#code试图从自身内部访问.NET库接收到的错误。
  • 复制的第三方.NET库到的VB6 code(也到system32文件夹下)的主文件夹。
    • 还是未找到文件...错误。
    • C# wrapped code completed.
    • VB6 code written, references the COM dll created.
    • "File not found..." error received when the C# code tries to access the .NET libraries from inside itself.
    • Copied the third party .NET libraries into the main folder of the VB6 code (also into system32 folder).
      • Still "File not found..." error.
      • 收到了同样的错误,因为VB6的code。
      • 在程序运行起来就好了。

      结论/问:

      • 在VB6可以呼叫/使用COM可调用封装的C#程序引用其他第三方.NET库?

      推荐答案

      这将反映有些由克里斯埃里克森的答案。

      This will mirror somewhat the answer by Kris Erickson.

      首先,我使用它解决了这些问题,我没有使用GAC。假设我的VB6应用是在C:\ Program Files文件\ myCompany中\ vb6app.exe,我把COM友好.NET的DLL(可以称之为net4vb.dll)与可执行文件的文件夹中。然后,我值寄存器使用RegAsm的/ codeBase的选项,该DLL有。最后,我把.NET程序集是我包裹或文件夹中使用(让purenet.dll称呼它)也是如此。

      First, for my usage which solves these problems, I did not use the GAC. Assuming that my VB6 application is in c:\program files\mycompany\vb6app.exe, I placed the COM-friendly .NET dll (lets call it net4vb.dll) in the folder with the executable. I then regsiter that dll there with RegAsm using the /codebase option. Finally, I place the .NET assembly that I'm wrapping or using (lets call it purenet.dll) in that folder as well.

      此时,vb6app.exe应该没有任何错误运行。

      At this point, vb6app.exe should run with no errors.

      如果您选择重要的是要注意的是,注册为COM Interop在Visual Studio中那么它将覆盖你在上面做了登记。所以,不要使用此选项。坚持只用这个命令行工具。

      It is important to note that if you select the "Register for COM Interop" in Visual Studio then it will overwrite the registration you did above. So do not use this option. Stick with the command-line tools only for this.

      这篇关于VB6对COM可调用包装的.NET - 问题,找到.NET库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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