• <small id='XFGo0'></small><noframes id='XFGo0'>

  • <i id='XFGo0'><tr id='XFGo0'><dt id='XFGo0'><q id='XFGo0'><span id='XFGo0'><b id='XFGo0'><form id='XFGo0'><ins id='XFGo0'></ins><ul id='XFGo0'></ul><sub id='XFGo0'></sub></form><legend id='XFGo0'></legend><bdo id='XFGo0'><pre id='XFGo0'><center id='XFGo0'></center></pre></bdo></b><th id='XFGo0'></th></span></q></dt></tr></i><div id='XFGo0'><tfoot id='XFGo0'></tfoot><dl id='XFGo0'><fieldset id='XFGo0'></fieldset></dl></div>
      <bdo id='XFGo0'></bdo><ul id='XFGo0'></ul>
  • <legend id='XFGo0'><style id='XFGo0'><dir id='XFGo0'><q id='XFGo0'></q></dir></style></legend>

    <tfoot id='XFGo0'></tfoot>

        如何从 vbScript 调用 .NET 代码 (C#/vb.net)?

        时间:2023-10-07
      1. <i id='f72b0'><tr id='f72b0'><dt id='f72b0'><q id='f72b0'><span id='f72b0'><b id='f72b0'><form id='f72b0'><ins id='f72b0'></ins><ul id='f72b0'></ul><sub id='f72b0'></sub></form><legend id='f72b0'></legend><bdo id='f72b0'><pre id='f72b0'><center id='f72b0'></center></pre></bdo></b><th id='f72b0'></th></span></q></dt></tr></i><div id='f72b0'><tfoot id='f72b0'></tfoot><dl id='f72b0'><fieldset id='f72b0'></fieldset></dl></div>
        <tfoot id='f72b0'></tfoot>

                <bdo id='f72b0'></bdo><ul id='f72b0'></ul>

                <small id='f72b0'></small><noframes id='f72b0'>

                  <tbody id='f72b0'></tbody>

                <legend id='f72b0'><style id='f72b0'><dir id='f72b0'><q id='f72b0'></q></dir></style></legend>

                  本文介绍了如何从 vbScript 调用 .NET 代码 (C#/vb.net)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想我可以编译一个 C# DLL,然后将它公开为一个 COM 对象,以便它可以从 VBscript 中创建对象.我只是不确定执行此操作所涉及的步骤...

                  I imagine I can compile a C# DLL and then expose it as a COM object so that it can be CreateObject'd from VBscript. I'm just not sure the steps involved in doing this...

                  推荐答案

                  这样做非常简单.但也有很多地方没那么简单.这在很大程度上取决于您的班级需要能够做什么,以及您打算如何部署它.

                  It can be very simple to do this. But there are a lot of places where it's not so simple. It depends a lot on what your class needs to be able to do, and how you intend to deploy it.

                  需要考虑的一些问题:

                  • 你的类必须有一个无参数的构造函数.
                  • 它不能暴露静态方法.
                  • 在全局程序集缓存中部署您的 COM DLL 好吗?如果没有,您将不得不给它一个强名称并使用 regasm/codebase 注册它.
                  • 您是否关心标识类及其接口的 GUID 是什么?如果没有,您可以让 regasm 分配它们,但是每次(和每个地方)注册课程时它们都会有所不同.如果您需要 GUID 在安装过程中保持不变,则需要使用 Guid 属性标记成员.
                  • 您打算在 .NET 和 COM 之间使用数据类型的默认编组吗?如果没有,您将需要使用 MarshalAs 属性标记属性和方法.
                  • 你的类公开什么样的 COM 接口对你来说很重要吗?如果是这样,您将需要处理 InterfaceType 属性.
                  • 您的班级是否需要提出或回应事件?如果是这样,就会对您设计类界面的方式产生影响.
                  • Your class has to have a parameterless constructor.
                  • It can't expose static methods.
                  • Is deploying your COM DLL in the global assembly cache OK? If not, you're going to have to give it a strong name and register it using regasm /codebase.
                  • Do you care what GUIDs identify the class and its interfaces? If not, you can let regasm assign them, but they'll be different every time (and every place) the class is registered. If you need the GUIDs to remain invariant across installations, you'll need to mark members with the Guid attribute.
                  • Are you going to use the default marshaling of data types between .NET and COM? If not, you're going to need to mark properties and methods with the MarshalAs attribute.
                  • Does it matter to you what kind of COM interface your class exposes? If so, you're going to need to deal with the InterfaceType attribute.
                  • Does your class need to raise or respond to events? If so, there are implications for how you design your class interface.

                  有一篇关于 COM 互操作和 .Net 的非常好的(如果过时的话)文章这里.(文章谈到的很多事情,比如生成类型库,现在都是自动为您处理的.)和 Microsoft 的文档 是最新的,但不是很详细.

                  There's a very good (if dated) article about COM interop and .Net here. (A lot of things that article talks about, like generating type libraries, is handled for you automatically now.) And Microsoft's documentation is up to date, but not quite so detailed.

                  这篇关于如何从 vbScript 调用 .NET 代码 (C#/vb.net)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:.NET 与 ASP.NET 与 CLR 与 ASP 下一篇:使用 Visual Studio 2008 远程调试 Web 应用程序的服务器端

                  相关文章

                  <i id='D2mSW'><tr id='D2mSW'><dt id='D2mSW'><q id='D2mSW'><span id='D2mSW'><b id='D2mSW'><form id='D2mSW'><ins id='D2mSW'></ins><ul id='D2mSW'></ul><sub id='D2mSW'></sub></form><legend id='D2mSW'></legend><bdo id='D2mSW'><pre id='D2mSW'><center id='D2mSW'></center></pre></bdo></b><th id='D2mSW'></th></span></q></dt></tr></i><div id='D2mSW'><tfoot id='D2mSW'></tfoot><dl id='D2mSW'><fieldset id='D2mSW'></fieldset></dl></div>
                1. <small id='D2mSW'></small><noframes id='D2mSW'>

                  <tfoot id='D2mSW'></tfoot>
                  <legend id='D2mSW'><style id='D2mSW'><dir id='D2mSW'><q id='D2mSW'></q></dir></style></legend>

                      • <bdo id='D2mSW'></bdo><ul id='D2mSW'></ul>