Groups | Blog | Home
all groups > dotnet interop > march 2008 >

dotnet interop : .Net Assembly from Classic ASP and VB6


JohnW
3/31/2008 9:50:58 PM
Hi All.

I've been asked to write a .Net assembly that will be accessed from a
couple of VB6 applications and some .ASP pages. I have a few general
type questions if someone could help.

I haven't been programming for long but this looks like a great chance
to earn some dollars and gain a lot of experience. I thought I'd
mention this as I'm assuming my lack of experience will be obvious :-)


Anyway, step one was to test access to the assembly from an asp page.
I created a Class library and used the "Register with COM Interop"
option on the project properties. Sure enough, I could access the test
class from asp using Server.CreatObject("TestDLL.TestClass")

One little problem was that I couldn't rebuild any further changes to
the assembly until I restarted IIS. VStudio couldn't overwrite the dll
as it was in use. Not a big deal really.

I was more interested in why I couldn't find my TestDLL in the
Component services MMC snapin. How it works when it isn't showing up
as a COM object is a bit of a mystery. Can anyone shed any light on
this?

Another issue was that when I reboot my workstation, my asp page could
no longer find the TestDLL. I had to load VStudio 2008 and build the
project again. Was the "Register with COM Interop" just a temorary
registration?

Adam
4/1/2008 7:58:00 AM
John,

You went right with the "Register with COM Interop" option. And yes, you
will likely find that trying to rebuild will fail due to IIS holding onto
your DLL. This is, of course, one of the symptoms of "DLL Hell" that .NET
tries to overcome, but since you are doing interop, you stil have to deal
with.

You won't see your component in the Component Services snapin because
"Register with COM Interop" only registers your assembly as a COM library,
not as a COM+/MTS component. I won't get into the differences, but you should
go read about COM+/MTS. You don't need them, however, to achieve simple
COM/.NET interop.

I'm not sure about why your ASP page couldn't find your assembly after
reboot. The "Register with COM Interop" option is not temporary, per se... it
doesn't back out when you close your project (that I know of!).

Hope this helps.

Adam

[quoted text, click to view]
JohnW
4/2/2008 9:25:23 AM
Hi Adam. Thanks for the response.

I'm reading up on the difference between the various versions of COM
and the history of COM objects.

I'm glad you cleared up the fact that I'm not registering a COM+
component but creating a COM library instead.

I've gone a step further and can now access my class library with asp
and VB6. Mainly because I rewrote my assembly using the "Com Class"
template instead of just a "Class" template for my initial class. I
can now refrence my assembly in VB6 (and get intellisense)


Now I have to read up on Interfaces. This is proving to be more fun
than I thought :-)

Oh, and now that I'm using classes with the "Com Class" templates I
see that VStudio2008 automatically selects "Register with COM Interop"
for me.

Thanks again.

JohnW

[quoted text, click to view]
AddThis Social Bookmark Button