Calling COM from ASP.NET

  • Thread starter Thread starter Sid
  • Start date Start date
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?
 
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!
**********************************************************************
 
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?
 
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
 
Back
Top