Deploying a VB.NET DLL

Hello,

I am pretty new to the .NET platform.  I have a question regarding deployment of a DLL to a Windows workstation.

I created a new VB.NET "Class Library" project.  

I created one Class in the project and Built the project into a DLL file.

When I used VB 6 I could take the DLL file and register it with windows using the regsvr32 command

I tried this with my DLL created in .NET and I get the following message:

BEGIN MESSAGE

C:\Source . . . TestClassLibrary.dll was loaded, but the DllRegisterServer entry point was not found.

DllRegisterServer may not be exported, or a corrupt version of C:\Source . . . TestClassLibrary.dll may be in memory. Consider using PView to detect and remove it.

END MESSAGE

I'm not sure what PView is or even if that is the correct thing to do to register a DLL created in VB.NET

Any Ideas?
LVL 3
aflat362Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aflat362Author Commented:
By the way,

Here is my entire Class file contents.  I'm just trying to get the windows DLL to work so I can develop a much more useful application

Thanks!

Public Class TestClassLibraryClass

    Private myAttribute As String

    Public Property attribute()
        Get
            Return myAttribute
        End Get

        Set(ByVal Value)
            myAttribute = Value
        End Set

    End Property

    Public Sub New()

    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
End Class
Zamba1Commented:
A DLL is not a DLL only because the extension is the same!

.NET creates "assemblies", VB6 creates "COM components". The internal structure of .NET assemblies is completely different than the structure of COM components. So registering (via regsvr32 and other ways) is useless for .NET assemblies, this is only valid for COM components.

You can compare the deployment of a .NET assembly roughly to the deployment of a standard Windows DLL: Usually you put it into the same directory where the application resides. If multiple applications need to use this file, you have _optionally_ the possibility to do something _similar_ like registering a COM component by storing the component into a shared storage called the "Global Assembly Cache".

Hope this gets you started !
Zamba
Arthur_WoodCommented:
1) make sure that the .NET DLL was configured o for 'INTEROPERABILITY' - check the Project Properties in Visual Studio.

2) you can then use RegASM to register a Com-Wrapper DLL which enables the .NET DLL to APPEAR as if it were COM-Compliant, so that it can be accessed by your VB 6 code.  YOu will also need to have the .NET Framework installed on the target PC.

Look up COM-Interoperability and RegASM in the .NET Help system - or go to the MSDN site on Microsoft.COM

check this URL:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_exch2k_using_com_interop_in_vb_net.asp

AW
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Zamba1Commented:
@Arthur_Wood: It seems to me that [aflat362] _used_ VB6 and is now using VB.NET, so it seems COM interop isn't required at all if VB6 or other COM clients are no longer part of the project. Am I correct with that?
davidlars99Commented:
you need a "Assembly Registration Tool" (regasm.exe), which comes with .NET framework.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfAssemblyRegistrationToolRegasmexe.asp

I think AW's link is to, how COM dll should be used with CLR thru Runtime Callable Wappers (RCW), and by the way aflat362, what do you need "Finalize" method for, you're not inheritting from the object that has one...? that way you are adding an extra overhead to the apllication when "Garbage Collection" comes in play.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
davidlars99Commented:
and you should never use Finalize method if your application unless you want to release some "unmanaged resources" taken by the application (Windows API and ODBC for example)
Arthur_WoodCommented:
ok, I misread the question.  

aflat362>>  .NET created DLLs are NOT registered, they are either placed in the /BIN folder which is under the folder where the EXE is located, or else they can be placed in the  GAC (Global Assembly Cache)

AW
davidlars99Commented:
and remember that, you can't use "regsvr32" to register .NET dll, use "regasm.exe"!
http://blogs.msdn.com/csharpfaq/archive/2004/08/02/206158.aspx
Arthur_WoodCommented:
you only use RegASM if you want to use the .NET DLL from a VB 6 application (as RegASM is used to register a COM-Compliant wrapper for the .NET DLL).

AW
Bob LearnedCommented:
I don't see anything that speaks to COM interoperability within this question.  It's about deploying .NET DLL's, and the way VB6 did it is confusing the issue.

Simplifying Deployment and Solving DLL Hell with the .NET Framework:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dplywithnet.asp

But, I guess since aflat362 is not responding it just becomes a conversation amongst ourselves.

Bob
aflat362Author Commented:
Just for clairity on the purpose of my application . . .

The DLL that I intend to develop will be accessed by an external application via the COM interface.

The external application is Kofax Ascent Capture - a vendor package that is used for scanning and indexing documents.

Ascent Capture allows you to extend the functionality of the product by writing your own code and accessing it via COM.

It seems that the .NET framework no longer uses COM and in order to write an application in .NET that uses com I have to

basically write a COM wrapper around the .NET application

>>and by the way aflat362, what do you need "Finalize" method for, you're not inheritting from the object that has one...?

I don't know - I'm more of a Java developer.  maybe I don't need it.

>>you can then use RegASM to register a Com-Wrapper DLL which enables the .NET DLL to APPEAR as if it were COM-Compliant, so that it can be accessed by your VB 6 code.  YOu will also need to have the .NET Framework installed on the target PC.

This makes it sound like I can "register" my .NET developed DLL with the new register tool and it should work just like before with the COM interface . . . correct?

That would be pretty sweet If I didn't have to develope a wrapper application myself.

Of course, there is always the option of simply developing my custom application with VB6.

Thoughts?




Bob LearnedCommented:
Ok, so I was wrong :)

Information, in this business, is KING :)

Bob
davidlars99Commented:
> It seems that the .NET framework no longer uses COM and in order to write an application in .NET that uses com I have to basically write a COM wrapper around the .NET application...

there are couple ways actualy, one of them is, you don't have to!
planoczCommented:
try this you may have to create  a setup file ...

http://www.siue.edu/~dbock/cmis460/6-deploy.htm
Zamba1Commented:
You have to take care about some things in .net - in your code - when writing an assembly for COM interop, such as GUIDs, visibility, HRESULTs, struct layouts, etc. ...,.

Quick link, just found: http://blogs.borland.com/cbensen/archive/2004/12/08/2111.aspx

If you want to keep things simple and .net is not absolutely necessary, do it VB6. ( but this is always an option of course, many do still program with VB6 ).
aflat362Author Commented:
Thanks for your input everyone.  I'm going to try and use the new assembly tool - if things don't go smoothly I'll just develop the application in VB6
aflat362Author Commented:
Alright . . .

I know I closed out the question already but here's a follow up question - I'll dole out points to whoever helps if my problem is solved

I tried registering the compiled .NET dll with RegAsm.exe I got a message saying that it was sucessful.

I checked the registry under HKEY_CLASSES_ROOT and sure enough, my object was there.

But when I tried creating an instance of the object via the COM interface from within Ascent Capture I get an error.

Unfortunately all I get is an error code 429 which translates to "Object creation failed"

Its beginning to look like I may actually HAVE to develop this DLL from .NET as the custom application will be making a web service
call.  I believe this is quite easy with .NET but a big pain with VB6.

Anyone know why my object didn't work over COM or does anyone have any suggestions as to what to do with my app (what languages or technologies could help me out here)

Thanks a lot!

aflat362Author Commented:
Ok - I got it to work.

I failed to closely heed ARTHUR_WOOD's advice

I forgot this step:

make sure that the .NET DLL was configured o for 'INTEROPERABILITY' - check the Project Properties in Visual Studio

I made the change, recompiled, reregistered and it works like a charm.

Thanks everyone!
davidlars99Commented:
very interesting thread... I've bookmarked it already  :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.