简体   繁体   中英

How do I use a COM component from VB.NET?

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

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.

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

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

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.

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

using ePadIIu;

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. Slower performance
  2. Possible memory leak due to blocked finalizer (not trying to be all doom and gloom, just seems to happen more often than not)

References discussing the problem:

Good Luck!
Z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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