如何使用VB.NET中的COM组件? [英] How do I use a COM component from VB.NET?

查看:916
本文介绍了如何使用VB.NET中的COM组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从ASP.NET页面访问COM组件。我添加了对我的ASP.NET项目的引用。

How do I access a COM component from an ASP.NET page. I added reference to my ASP.NET project.

我从第三方获得的实际dll是 ePadIIu.dll ,但是当我把它添加到ASP。 NET项目,它显示为 ePadIIu.interop

The actual dll I got from the 3rd party is ePadIIu.dll but when I added it to the ASP.NET project it shows as ePadIIu.interop.

我想访问组件中的所有方法和属性。

I want to access all the methods and properties in the component.

我从第三方软件收到的示例使用vbscript访问所有方法。

The sample I received from the 3rd party software uses vbscript to access all the methods.

如何在 default.aspx.vb 后面的代码中使用这些方法。

How do I use those methods in the code behind from default.aspx.vb.

推荐答案

当您从ASP.NET项目添加对COM组件的引用时,Visual Studio通过tblimp(类型库导入实用程序)用于.NET的互操作程序集。按照惯例,它命名为ePadIIu.interop.dll。

When you added the reference to the COM component from your ASP.NET project, Visual Studio ran it through tblimp (type library import utility) to generate an interop assembly for use with .NET. By convention, it named it ePadIIu.interop.dll.

如果在对象浏览器中查看此引用,您应该能够确定需要引用的命名空间以及任何类,属性和方法

If you view this reference in the Object Browser, you should be able to determine the namespace you will need to reference, as well as any of the classes, properties and methods exposed.

您的* .cs顶部的使用语句可能如下所示:

Your using statement at the top of your *.cs might look something like this:

using ePadIIu;

小心 - 湿滑时滑溜

VB COM组件是臭名昭着的使用单线程公寓(STA)编译 - 虽然不总是这种情况(如果我记得正确)。如果ePadIIu恰好是STA COM组件,您可能会遇到:

Caution - Slippery When Wet
VB COM components are notorious for being compiled using a Single Threaded Apartment (STA) - though not always the case (if I remember correctly). If ePadIIu happens to be a STA COM component you might experience:


  1. 性能降低


参考文献讨论了问题:

  • COM Interoperability in the .NET Framework
  • Running ASMX services on STA Threads
  • Developing High Performance ASP.NET Websites
  • ASP.NET Hang and OutOfMemoryException caused by STA Components

好运!

Z

Good Luck!
Z

这篇关于如何使用VB.NET中的COM组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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