Calling COM from ASP.NET

S

Sid

Is it possible to call compiled COM components directly
from ASP.NET without having to set a reference to them
using the IDE?

e.g. in ASP you could use Server.CreateObject("somedll")
but for some reason this does not work in ASP.NET, is this
actually possible?
 
C

Cowboy \(Gregory A. Beamer\)

The reference is necessary, as you have to create the .NET callable wrapper
for the COM component. There is interop involved when you go across the
COM/.NET barrier.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
S

Sid

Thanks for replying, can I just clarify, if I am therefore
writing ASP.NET pages using notepad, then I am unable to
call COM components that I have previously created in VB
6.0? Or is it possible to set a reference to a dll
programmatically?
 
D

David Browne

Sid said:
Thanks for replying, can I just clarify, if I am therefore
writing ASP.NET pages using notepad, then I am unable to
call COM components that I have previously created in VB
6.0? Or is it possible to set a reference to a dll
programmatically?

First off, you don't need an interop assembly.

If you are using VB, at least, you can just use CreateObject and late
binding.

Dim d As Object = CreateObject("MyComponent.MyClass")
d.DoSomething()

This will use late binding to access the component, just like in classic
ASP.

If you want to early-bind to the component, you do need an interop assembly.
But you still don't need VS. You can use tlbimp.exe to generate the interop
assembly, and then add a directive to your aspx page to reference it.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top