install a c# com dll for use by vbscript classic a

2019-08-02 03:05发布

问题:

I have a Classic ASP website with vb6 dll's and all is ok with the world, but now I have some extra functionality that has been completed using c# into a COM DLL. In the dev environment this is working, but now I wish to move this DLL onto another machine.

My question is what is the best way to do this?

I have seen answers such as "add it to the GAC" or, "in needs a strong name", etc.

What happened to the good old regsvr32?

回答1:

Regsvr32 is still relevant today but you can't use it with .NET, only native DLLs. .NET has a special way to register COM-types as we shall soon see.

Regsvr32 works by invoking the DllRegisterServer export. DllRegisterServer gives the library a chance to register COM classes; type libraries; interfaces etc. This export is not present in .dlls created by .NET which makes sense because they are not COM by default. You can easily see these differences if you open up a .NET or non-.NET .dll in Dependency Walker/Viewer.

Here's a native c++ ActiveX dll I made earlier (Note the DllRegisterServer export on the right):

And here is a managed .dll. (Note there are no exports let alone DllRegisterServer):

If you have marked your c# class as COM-visible then you can complete the COM-registration by invoking:

regasm assemblyFile[options]

Tell me more

This will place the necessary entries into the Windows Registry.

There is no need for the GAC because native COM clients (VB6) do not use the GAC



标签: c# dll vb6