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

查看:294
本文介绍了如何使用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.

我如何使用在code后面这些方法从 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. 性能下降

  2. 由于堵塞终结可能的内存泄漏(不试图将所有的危困,只是似乎更经常发生比不了)

引用讨论的问题:

  • 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

祝您好运!

ž

Good Luck!
Z

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

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