VB dll files

  • Thread starter Thread starter Daryl Davis
  • Start date Start date
You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that will
be used by a VB 6 front-end you will need to deploy the .NET Framework to
the machines that will use the DLL.
 
What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to speak.
Daryl

Rob Windsor said:
You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that will
be used by a VB 6 front-end you will need to deploy the .NET Framework to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Daryl Davis said:
Can I still write dll files in Visual basic.net?
 
Hi Daryl,

..NET handles that for you! If you're using Visual Studio just go to the "Add
Reference" dialog and pick your VB 6 DLL from the list in the COM tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command line
utility which is part of the .NET Framework SDK. See the link below for more
info on this utility

http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Daryl Davis said:
What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to speak.
Daryl

Rob Windsor said:
You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that will
be used by a VB 6 front-end you will need to deploy the .NET Framework to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Daryl Davis said:
Can I still write dll files in Visual basic.net?
 
This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices today,
but by the time I was able to try it out, I was unable to call any of my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services. Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once you
have an instance, use Type.InvokeMember to call methods.properties by name
AlexFeinman_MVP : .

Rob Windsor said:
Hi Daryl,

.NET handles that for you! If you're using Visual Studio just go to the "Add
Reference" dialog and pick your VB 6 DLL from the list in the COM tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command line
utility which is part of the .NET Framework SDK. See the link below for more
info on this utility

http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Daryl Davis said:
What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to speak.
Daryl

Rob Windsor said:
You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the .NET Framework to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
Hi Daryl,

Alex is right, you can do it that way but you can also do it using a more VB
6 style. The CreateObject function is still available in VB.NET so you could
use:

Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course be
preferred.

Rob



Daryl Davis said:
This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices today,
but by the time I was able to try it out, I was unable to call any of my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services. Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once you
have an instance, use Type.InvokeMember to call methods.properties by name
AlexFeinman_MVP : .

Rob Windsor said:
Hi Daryl,

.NET handles that for you! If you're using Visual Studio just go to the "Add
Reference" dialog and pick your VB 6 DLL from the list in the COM tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command line
utility which is part of the .NET Framework SDK. See the link below for more
info on this utility
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Daryl Davis said:
What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to speak.
Daryl

You can use VB.NET (or C#) to create the equivalent to a VB 6
ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that
will
be used by a VB 6 front-end you will need to deploy the .NET
Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
If I early bind a reference locally can I use it like this?
Dim obj As Object
dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3
obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
intReturn = obj.myfunction(param1,param2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course be
preferred.

Rob



Daryl Davis said:
This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices today,
but by the time I was able to try it out, I was unable to call any of my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services. Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once you
have an instance, use Type.InvokeMember to call methods.properties by name
AlexFeinman_MVP : .

the
"Add for
more
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to
speak.
Daryl

You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that
will
be used by a VB 6 front-end you will need to deploy the .NET Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
I should also state that this is in a web service so that smartdevices can
access the dll. (I hope that doesn't throw this whole thing off...)
Daryl
Rob Windsor said:
Hi Daryl,

Alex is right, you can do it that way but you can also do it using a more VB
6 style. The CreateObject function is still available in VB.NET so you could
use:

Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course be
preferred.

Rob



Daryl Davis said:
This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices today,
but by the time I was able to try it out, I was unable to call any of my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services. Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once you
have an instance, use Type.InvokeMember to call methods.properties by name
AlexFeinman_MVP : .

the
"Add for
more
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to
speak.
Daryl

You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET that
will
be used by a VB 6 front-end you will need to deploy the .NET Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
You've kind of got the right idea. Let's look at two examples:

Ex A:
Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")

Ex B:
Dim obj As MyComp.MyClass
obj = CreateObject("MyComp.MyClass", "MyServer")

The variable in Ex A is late bound. The compiler knows that it will refer to
an object but it has no idea what kind of object thus all calls to methods
or properties will be resolved at run time.

The variable in Ex B is early bound. The compiler knows it is refering to an
object of type MyClass and will use the metadata from the assembly (which
was generated from the type library of the COM component) to validate all
calls to methods or properties at compile time.

Hope this helps,

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada



Daryl Davis said:
If I early bind a reference locally can I use it like this?
Dim obj As Object
dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3
obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
intReturn = obj.myfunction(param1,param2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course be
preferred.

Rob



remote
MTS
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped so to
speak.
Daryl

You can use VB.NET (or C#) to create the equivalent to a VB 6 ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the .NET Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
Rob,
Then my problem must be that I am trying from a web service, or I am missing
something very basic. When I try to early bind I get the error "
Cannot convert to 'Interface salesDO'.
"
SalesDO is the class on the dll I am trying to call.
and when I try late binding and try call I get "
Run-time exception thrown : System.NullReferenceException - Object reference
not set to an instance of an object.
"
My test code (usually typed out in command window but here for example)....
try
Dim trying as hallsales.salesdo
dim sale as object
trying = createobject("hallsales.salesdo","\\192.168.10.1")
sale = createobject("hallsales.salesdo","\\192.168.10.1")
input = hallsales.saleTable2
input.CreditAmt = 20

input.posStation = 9

input.UserID = 5

trying.sellfrompos(input,true)
sale.sellfrompos(input,true)
catch ex
end try

Do you have any ideas? I know I must be missing something small, but
important.
Daryl Davis
Rob Windsor said:
You've kind of got the right idea. Let's look at two examples:

Ex A:
Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")

Ex B:
Dim obj As MyComp.MyClass
obj = CreateObject("MyComp.MyClass", "MyServer")

The variable in Ex A is late bound. The compiler knows that it will refer to
an object but it has no idea what kind of object thus all calls to methods
or properties will be resolved at run time.

The variable in Ex B is early bound. The compiler knows it is refering to an
object of type MyClass and will use the metadata from the assembly (which
was generated from the type library of the COM component) to validate all
calls to methods or properties at compile time.

Hope this helps,

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada



Daryl Davis said:
If I early bind a reference locally can I use it like this?

dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3

intReturn = obj.myfunction(param1,param2) course
be
of
my services.
Can Once
you by
name to
the command
line below
for
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it wrapped
so
to
speak.
Daryl

message
You can use VB.NET (or C#) to create the equivalent to a VB 6
ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB (more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the .NET
Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
sorry input = hallsales.saleTable2 is supposed to be
dim input as hallsales.saletable2
Daryl
Daryl Davis said:
Rob,
Then my problem must be that I am trying from a web service, or I am missing
something very basic. When I try to early bind I get the error "
Cannot convert to 'Interface salesDO'.
"
SalesDO is the class on the dll I am trying to call.
and when I try late binding and try call I get "
Run-time exception thrown : System.NullReferenceException - Object reference
not set to an instance of an object.
"
My test code (usually typed out in command window but here for example)....
try
Dim trying as hallsales.salesdo
dim sale as object
trying = createobject("hallsales.salesdo","\\192.168.10.1")
sale = createobject("hallsales.salesdo","\\192.168.10.1")
input = hallsales.saleTable2
input.CreditAmt = 20

input.posStation = 9

input.UserID = 5

trying.sellfrompos(input,true)
sale.sellfrompos(input,true)
catch ex
end try

Do you have any ideas? I know I must be missing something small, but
important.
Daryl Davis
Rob Windsor said:
You've kind of got the right idea. Let's look at two examples:

Ex A:
Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")

Ex B:
Dim obj As MyComp.MyClass
obj = CreateObject("MyComp.MyClass", "MyServer")

The variable in Ex A is late bound. The compiler knows that it will
refer
to
an object but it has no idea what kind of object thus all calls to methods
or properties will be resolved at run time.

The variable in Ex B is early bound. The compiler knows it is refering
to
an
object of type MyClass and will use the metadata from the assembly (which
was generated from the type library of the COM component) to validate all
calls to methods or properties at compile time.

Hope this helps,

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada



Daryl Davis said:
If I early bind a reference locally can I use it like this?

Dim obj As Object
dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3

obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
intReturn = obj.myfunction(param1,param2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course
be
preferred.

Rob



This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices
today,
but by the time I was able to try it out, I was unable to call any
of
my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services.
Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote
MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once
you
have an instance, use Type.InvokeMember to call methods.properties by
name
AlexFeinman_MVP : .

Hi Daryl,

.NET handles that for you! If you're using Visual Studio just go to
the
"Add
Reference" dialog and pick your VB 6 DLL from the list in the
COM
tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command
line
utility which is part of the .NET Framework SDK. See the link below
for
more
info on this utility
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it
wrapped
so
to
speak.
Daryl

message
You can use VB.NET (or C#) to create the equivalent to a VB 6
ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB
(more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the .NET
Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
Hi Daryl,

Sorry, I'm out of ideas. I'd guess it was a security issue but the error
messages you're getting don't point to that.

The last thing I would suggest is to create a small VB 6 test app that calls
your component, get that working then copy the code over to a test VB.NET
app and get that working (it should without any changes). Once your sure
that you can access your component using a windows app then you can narrow
down the possible problems.

Rob

Daryl Davis said:
Rob,
Then my problem must be that I am trying from a web service, or I am missing
something very basic. When I try to early bind I get the error "
Cannot convert to 'Interface salesDO'.
"
SalesDO is the class on the dll I am trying to call.
and when I try late binding and try call I get "
Run-time exception thrown : System.NullReferenceException - Object reference
not set to an instance of an object.
"
My test code (usually typed out in command window but here for example)....
try
Dim trying as hallsales.salesdo
dim sale as object
trying = createobject("hallsales.salesdo","\\192.168.10.1")
sale = createobject("hallsales.salesdo","\\192.168.10.1")
input = hallsales.saleTable2
input.CreditAmt = 20

input.posStation = 9

input.UserID = 5

trying.sellfrompos(input,true)
sale.sellfrompos(input,true)
catch ex
end try

Do you have any ideas? I know I must be missing something small, but
important.
Daryl Davis
Rob Windsor said:
You've kind of got the right idea. Let's look at two examples:

Ex A:
Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")

Ex B:
Dim obj As MyComp.MyClass
obj = CreateObject("MyComp.MyClass", "MyServer")

The variable in Ex A is late bound. The compiler knows that it will
refer
to
an object but it has no idea what kind of object thus all calls to methods
or properties will be resolved at run time.

The variable in Ex B is early bound. The compiler knows it is refering
to
an
object of type MyClass and will use the metadata from the assembly (which
was generated from the type library of the COM component) to validate all
calls to methods or properties at compile time.

Hope this helps,

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada



Daryl Davis said:
If I early bind a reference locally can I use it like this?

Dim obj As Object
dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3

obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
intReturn = obj.myfunction(param1,param2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course
be
preferred.

Rob



This is what I understand. What I don't understand is how I make the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices
today,
but by the time I was able to try it out, I was unable to call any
of
my
functions. I think it is that I am just unable to understand this area
because it has been thrown on me and I am just learning web services.
Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a remote
MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once
you
have an instance, use Type.InvokeMember to call methods.properties by
name
AlexFeinman_MVP : .

Hi Daryl,

.NET handles that for you! If you're using Visual Studio just go to
the
"Add
Reference" dialog and pick your VB 6 DLL from the list in the
COM
tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command
line
utility which is part of the .NET Framework SDK. See the link below
for
more
info on this utility
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it
wrapped
so
to
speak.
Daryl

message
You can use VB.NET (or C#) to create the equivalent to a VB 6
ActiveX
DLL
using COM Interop. These DLLs could be used by .NET apps or VB
(more
specificaly COM) apps. NOTE: If you want to create a DLL in VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the .NET
Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
Thanks Rob.
I appreciate all your help. Hopefully someone in the webservice group can
help me then.
Daryl
Rob Windsor said:
Hi Daryl,

Sorry, I'm out of ideas. I'd guess it was a security issue but the error
messages you're getting don't point to that.

The last thing I would suggest is to create a small VB 6 test app that calls
your component, get that working then copy the code over to a test VB.NET
app and get that working (it should without any changes). Once your sure
that you can access your component using a windows app then you can narrow
down the possible problems.

Rob

Daryl Davis said:
Rob,
Then my problem must be that I am trying from a web service, or I am missing
something very basic. When I try to early bind I get the error "
Cannot convert to 'Interface salesDO'.
"
SalesDO is the class on the dll I am trying to call.
and when I try late binding and try call I get "
Run-time exception thrown : System.NullReferenceException - Object reference
not set to an instance of an object.
"
My test code (usually typed out in command window but here for example)....
try
Dim trying as hallsales.salesdo
dim sale as object
trying = createobject("hallsales.salesdo","\\192.168.10.1")
sale = createobject("hallsales.salesdo","\\192.168.10.1")
input = hallsales.saleTable2
input.CreditAmt = 20

input.posStation = 9

input.UserID = 5

trying.sellfrompos(input,true)
sale.sellfrompos(input,true)
catch ex
end try

Do you have any ideas? I know I must be missing something small, but
important.
Daryl Davis
Rob Windsor said:
You've kind of got the right idea. Let's look at two examples:

Ex A:
Dim obj As Object
obj = CreateObject("MyComp.MyClass", "MyServer")

Ex B:
Dim obj As MyComp.MyClass
obj = CreateObject("MyComp.MyClass", "MyServer")

The variable in Ex A is late bound. The compiler knows that it will
refer
to
an object but it has no idea what kind of object thus all calls to methods
or properties will be resolved at run time.

The variable in Ex B is early bound. The compiler knows it is refering
to
an
object of type MyClass and will use the metadata from the assembly (which
was generated from the type library of the COM component) to validate all
calls to methods or properties at compile time.

Hope this helps,

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada



If I early bind a reference locally can I use it like this?

Dim obj As Object
dim param1 as MyComp.MyClass.MyType
dim param2 as boolean = false
dim intReturn as integer

param1.int1 = 1
param1.string1 = "trial and error"
param1.int2 = 3

obj = CreateObject("MyComp.MyClass", "MyServer")
' use object
intReturn = obj.myfunction(param1,param2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing

Note this code shows how to use the object late bound and requires
Option
Strict Off. You can do this early bound by setting a reference to your
component and using a variable to the correct type, this would of course
be
preferred.

Rob



This is what I understand. What I don't understand is how I
make
the
program go to the MTS server (another machine) for all the calls..
I got some advice from AlexFeinman_MVP on the chat about smartdevices
today,
but by the time I was able to try it out, I was unable to call
any
of
my
functions. I think it is that I am just unable to understand this
area
because it has been thrown on me and I am just learning web services.
Can
you help shed some light.
Thank you,
Daryl
<snip from chat>
AlexFeinman_MVP : Q: How do I write a web service that uses a
remote
MTS
component written in VB6 (using late binding)
AlexFeinman_MVP : A: Use Dim t as Type =
Type.GetFromProgID(componentProgID) to obtain a runtime type and then
Activator.CreateInstance to create an instance of the component. Once
you
have an instance, use Type.InvokeMember to call
methods.properties
by
name
AlexFeinman_MVP : .

message
Hi Daryl,

.NET handles that for you! If you're using Visual Studio just
go
to
the
"Add
Reference" dialog and pick your VB 6 DLL from the list in the COM
tab.
Visual Studio will create a .NET DLL wrapper for you automatically.

You you're not using VS then you need to use the tlbimp.exe command
line
utility which is part of the .NET Framework SDK. See the link below
for
more
info on this utility
http://msdn.microsoft.com/library/d...ls/html/cpgrfTypeLibraryImporterTlbimpexe.asp
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


What I want to do....
is write a .net dll to call vb6 dll's so that i have it
wrapped
so
to
speak.
Daryl

VB
or
VB
(more
specificaly COM) apps. NOTE: If you want to create a DLL in
VB.NET
that
will
be used by a VB 6 front-end you will need to deploy the ..NET
Framework
to
the machines that will use the DLL.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


Can I still write dll files in Visual basic.net?
 
Back
Top