Class Library

T

Tibby

Add this Code
<ComClass(Rythmia.ClassID, Rythmia.InterfaceId, Rythmia.EventsId)> _
Public Class Class1
#Region "COM Class IDs"
Public Const ClassID As String = "5F0D4112-B23D-4703-94F5-B5B96E50F3BB"
Public Const InterfaceId As String =
"A9DFEE4E-3DBB-4505-BBC6-9BCEE5A220A5"
Public Const EventsId As String = "E6CAB551-4A34-4c4d-83EA-7D3D7E2E49DF"
#End Region
Sub Main()
End Sub
End Class

This makes your DLL emulate an ActiveX control. From here, you can register
it, or select the option in the project properties to register it for COM
interop. One thing to remember about the ID's, you need to use the utility
Registry Format. Otherwise, should work just fine.

Good Luck and HTH
Tibby

news:[email protected]...
 
A

Armin Zingler

Luis Gustavo said:
Good afternoon.

I would like to know if is possible use a dll made in Vb.net in VB
6.

I made this to test the dll:

Imports System.Data

Imports System.Xml

Public Class RH

Public Shared Function addHistory(ByVal txtFind As String, ByVal
txtReplace As String) As String

Return "Luis Gustavo Aleixo"

End Function

End Class

the code is rigth, when I try to register with the command "regsvr32"
happen a error:
"---------------------------
RegSvr32
---------------------------
ReplaceHistory.dll was loaded, but the DllRegisterServer entry point
was not found.

DllRegisterServer may not be exported, or a corrupt version of
ReplaceHistory.dll may be in memory. Consider using PView to detect
and remove it.
"
What I need to make to use the dll in VB 6?


You probably already know that VB6 can create and use COM/ActiveX DLLs or
use "standard" DLLs. As VB.Net creates managed assemblies they are based on
(completely) different techniques. However, you can also create COM Interop
wrappersin VB.Net. An entry point is here:

http://msdn.microsoft.com/library/en-us/vbcon/html/vbconCOMInteropInVisualBasicVisualC.asp

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp

http://msdn.microsoft.com/library/e...roughCreatingCOMObjectsWithVisualBasicNET.asp


You'll also find these (and from there other topics) in the <F1> docs.
 
T

Tibby

I need to make one minor correction, in this portion:
<ComClass(Rythmia.ClassID, Rythmia.InterfaceId, Rythmia.EventsId)> ;
Rythmia is the name of my class, so it should read Class1 in this example.
 
L

Luis Gustavo

Good afternoon.

I would like to know if is possible use a dll made in Vb.net in VB 6.

I made this to test the dll:

Imports System.Data

Imports System.Xml

Public Class RH

Public Shared Function addHistory(ByVal txtFind As String, ByVal txtReplace
As String) As String

Return "Luis Gustavo Aleixo"

End Function

End Class

the code is rigth, when I try to register with the command "regsvr32" happen
a error:
"---------------------------
RegSvr32
---------------------------
ReplaceHistory.dll was loaded, but the DllRegisterServer entry point was not
found.

DllRegisterServer may not be exported, or a corrupt version of
ReplaceHistory.dll may be in memory. Consider using PView to detect and
remove it.
"
What I need to make to use the dll in VB 6?

Luis Gustavo - Brazil

msn: (e-mail address removed)
 
A

Alireza Kheyrollahi

Not to forget type library guid:

<Assembly: Guid("6489269F-2E92-448B-96AF-A9C70B7C8E71")> in file
AssemblyInfo.vb

Your class must always have a public parameterless constructor. Constructors
with parameters or shared properties/methods/fields are not accessible.

You may use Regasm.exe to create type libarary, reg file or install your
assembly on client machines. But be careful what you expose to Non.NET
world!

Cheers
Ali
 
A

Armin Zingler

Luis Gustavo said:
Code:
===================================

I build the solution and is OK !!!

then I open the prompt and execute the command "regasm.exe" so
"regasm replacehistory.dll" and display the message:
"Microsoft (R) .NET Framework Assembly Registration Utility
1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002.  All
rights reserved.

Types registered successfully"

I try too: "regasm ReplaceHistory.dll /regfile:rh.reg" and display
the message:
"
Microsoft (R) .NET Framework Assembly Registration Utility
1.1.4322.57 Copyright (C) Microsoft Corporation 1998-2002.  All
rights reserved.

Registry script 'C:\Documents and Settings\gustavo\My
Documents\VBdotN ace\ReplaceHistory\ReplaceHistory\bin\rh.reg'
generated successfully "
and open the reg file.[/QUOTE]


You don't have to execute regasm. If "[x] register for COM interop" is
checked in the project properties, it is automatically registered.
[QUOTE]
when I try to execute "regsvr32", the same message is display.[/QUOTE]

You don't need regsvr32.
 
L

Luis Gustavo

First, thank for your helps !!!
What I'm doing wrong ?

the code:

class1.vb:
===================================
Imports System.Data

Imports System.Xml

<ComClass(RH.ClassID, RH.InterfaceId, RH.EventsId)> _

Public Class RH

#Region "COM Class IDs"

Public Const ClassID As String = "5F0D4112-B23D-4703-94F5-B5B96E50F3BB"

Public Const InterfaceId As String = "A9DFEE4E-3DBB-4505-BBC6-9BCEE5A220A5"

Public Const EventsId As String = "E6CAB551-4A34-4c4d-83EA-7D3D7E2E49DF"

#End Region

Public val As Integer

Public Sub New()

val = 0

End Sub

Public Function addHistory(ByVal txtFind As String, ByVal txtReplace As
String) As String

Return "Luis Gustavo Aleixo"

End Function

End Class

===================================
AssemblyInfo.vb:
===================================
Imports System

Imports System.Reflection

Imports System.Runtime.InteropServices

<Assembly: AssemblyTitle("")>

<Assembly: AssemblyDescription("")>

<Assembly: AssemblyCompany("")>

<Assembly: AssemblyProduct("")>

<Assembly: AssemblyCopyright("")>

<Assembly: AssemblyTrademark("")>

<Assembly: CLSCompliant(True)>

'<Assembly: Guid("E8C42458-4ED8-4485-8145-A364D099BC5B")>

<Assembly: Guid("6489269F-2E92-448B-96AF-A9C70B7C8E71")>

<Assembly: AssemblyVersion("1.0.*")>

===================================

I build the solution and is OK !!!

then I open the prompt and execute the command "regasm.exe" so "regasm
replacehistory.dll" and display the message:
"Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Types registered successfully"

I try too: "regasm ReplaceHistory.dll /regfile:rh.reg" and display the
message:
"
Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.57
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Registry script 'C:\Documents and Settings\gustavo\My Documents\VBdotN
ace\ReplaceHistory\ReplaceHistory\bin\rh.reg' generated successfully
"
and open the reg file.

when I try to execute "regsvr32", the same message is display.
 
A

Alireza Kheyrollahi

On development machine yes but not on production machine... You need to
register the component on the client. I usually create reg file and then
manually edit it (chop off unrelated bits) and then run it on client.


Armin Zingler said:
Luis Gustavo said:
Code:
===================================

I build the solution and is OK !!!

then I open the prompt and execute the command "regasm.exe" so
"regasm replacehistory.dll" and display the message:
"Microsoft (R) .NET Framework Assembly Registration Utility
1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002.  All
rights reserved.

Types registered successfully"

I try too: "regasm ReplaceHistory.dll /regfile:rh.reg" and display
the message:
"
Microsoft (R) .NET Framework Assembly Registration Utility
1.1.4322.57 Copyright (C) Microsoft Corporation 1998-2002.  All
rights reserved.

Registry script 'C:\Documents and Settings\gustavo\My
Documents\VBdotN ace\ReplaceHistory\ReplaceHistory\bin\rh.reg'
generated successfully "
and open the reg file.[/QUOTE]


You don't have to execute regasm. If "[x] register for COM interop" is
checked in the project properties, it is automatically registered.
[QUOTE]
when I try to execute "regsvr32", the same message is display.[/QUOTE]

You don't need regsvr32.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
[/QUOTE]
 
A

Alireza Kheyrollahi

Luis,

You should not use regsvr32! Forget about it completely in .NET world!
I have a sample retg file in the office that I will send you tomorrow. But:

1. Why do you have two assembly GUIDs? See:
'<Assembly: Guid("E8C42458-4ED8-4485-8145-A364D099BC5B")>

<Assembly: Guid("6489269F-2E92-448B-96AF-A9C70B7C8E71")>


Only the last one will be used.

2. You have to use codebase switch that points to your assembly while using
REGASM.EXE. Just run regasm.exe /? to get help or use MSDN to see how that
switch works. You also can add the "codebase" registy entry yourself but it
is more prone to errors.

I know these because I spent half of a day finding my way through poor
explanations of MSDN (Sorry Bill Gates!).

Good luck
Ali
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top