Using VS 2008 (vb.net) I need to create an object I can use in Classic ASP with CreateObject
Asked Answered
H

3

1

I am very new to VB.net. I have written these objects in VB6 before. I'm just lost in VB.net, but (kicking and screaming) I have to learn how to do this. I've been googling for hours with only minor steps forward. Can anyone post a link that explains start to finish how to do this?

I have managed to write the class object, What I can not tell is how to register it and where the name1 and name2 in the CreateObject("Name1.Name2") come from.

Regsrv32 will not work. It says "Entry Point not found" and will not register it. Also, I can not drop it into the Assemblies directory. I read something about a regasm command one uses, but I can't seem to make this work either.

Thanks in advance for any assistance.

Homelike answered 9/11, 2008 at 17:16 Comment(0)
V
2

I am going to assume you are not trying to write a COM DLL but rather a complete project that call various sub assemblies like a VB6 EXE call a ActiveX DLL. If you can be more specific about what you are trying to do it would help me better.

Several points about VB.NET versus VB6.

1) For .NET only projects there is no registration. If a EXE or DLL references another .NET DLL the only requirement is that the DLLs be present in the parent's directory.

2) You can do a COM style registration for .NET apps only by registering the .NET assembly in the GAC. However there are several requirements for doing this. Do a search on the .NET GAC and it will give you the scoop on how to do this.

3) You can setup the .NET assembly to use COM in which case it will operate by the rules of COM including registration with regsvr.

You will find for .NET only project that #2, or #3 only come in rare instances. #1 will apply for 90% of your DLL assemblies. Of This is dependent on your project.

A common use for CreateObject is allow for plug-ins or installable libraries. .NET handles this through the Reflection API. With the reflection API you can look in a directory, go through each .NET DLL and see what them and create objects from what you find. Search for .NET Reflection to read up on this.

If your project is .NET only then I recommend that you create a Assembly that is reference by both the master assembly and the individual sub assembly that define the interfaces of the objects you are creating. This when you use the reflection API and determine the Object type you can assign it to a variable of that interface and code it noramlly with intellisense and other aids.

if you have old COM ActiveX Controls or DLLs .NET will generate a wrapper class that exposes the ActiveX Objects to .NET. I would spend some time learning how .NET does this. What I do create a dummy project and have .NET reference the ActiveX stuff I need. I then find the wrapper projects and DLL it made and move them into a central area. That why when I work on subsquent projects using the same ActiveX stuff I know where all the wrappers are.

Venn answered 10/11, 2008 at 13:25 Comment(2)
You do not have to install into the GAC for interop. Regasm with the codebase switch will allow you to place outside the GAC.Eniwetok
I wasn't talking about COM Interop. But the different ways that .NET can share assemblies. You presume that the questioner was talking about COM. My answer doesn't assume that rather focuses on the myriad ways .NET share assemblies.Venn
T
1

You have to go to your class library properties and select the option "Register for COM interop". This will make your assembly available to COM.

Tarpeia answered 9/11, 2008 at 17:23 Comment(0)
E
-1

You want to create what's called a COM Callable Wrapper (aka CCW) for your .NET component. This basically entails setting up some COM interfaces with some GUIDs and either enabling "Register for COM Interop" in the project properties (as mentioned) or using regasm.exe.

Eniwetok answered 9/11, 2008 at 18:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.