CreateObject( )... :(

P

Pauras Desani

Dear friends,
I have developed a module in VB6 and now I want to redevelop it into
..NET .

VB6
Dim cat as Object
Set cat =GetObject("","ABC.Application")
Dot NET
Dim cat as Object
Set cat =GetObject("","ABC.Application")
I don't have deep knowledge of Dot NET so I use this code and its
working.

It runs smoothly when the application is running. But in VB6 if the
application is not working then it shows an error "ActiveX component
can not create object". But in Dot NET I don't get this error
message?. But I need the error message so that I can find out whether
the application is working or not? Or how can I know that ABC
application is running or not.

Thanks in Advance.
 
L

Lucky

u can use "System.Diagnostics" namespace to get all the processes
running on your machine and thus u can find out whether your app is
running or not.

by the way what u got in your object when you call the GetObject()
function and the abc application is not running?
 
H

Herfried K. Wagner [MVP]

Pauras Desani said:
VB6
Dim cat as Object
Set cat =GetObject("","ABC.Application")
Dot NET
Dim cat as Object
Set cat =GetObject("","ABC.Application")
I don't have deep knowledge of Dot NET so I use this code and its
working.

It runs smoothly when the application is running. But in VB6 if the
application is not working then it shows an error "ActiveX component
can not create object". But in Dot NET I don't get this error
message?. But I need the error message so that I can find out whether
the application is working or not?

Untested:

\\\
Dim cat As Object = GetObject(...)
If cat Is Nothing Then
MsgBox("Application not working!")
Else
...
End If
///
 
M

m.posseth

when i did some testing with our VB6 activex app ( a verry long time ago
:) )
i was told to do it like this


'Import Reflection Namspace which supports COM interoperability

Imports System.Reflection

private HBSObject as object

in the method to start the component

Dim HBSCOM As Type

'Get the object

HBSCOM = Type.GetTypeFromProgID("Hbase.clsHbase")

'Create instance of HBSCOM

Addtekst("Creating instance ")

HBSObject = Activator.CreateInstance(HBSCOM)

If Not (HBSObject Is Nothing) Then

do your stuff here

End If



in the close / cleanup method

System.Runtime.InteropServices.Marshal.ReleaseComObject(HBSObject)

HBSObject = Nothing



regards



Michel Posseth [MCP]
 

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