• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Exposing an Object in VB6 that can be used in standard ASP script

I need to be able to pass a text string from my ASP script to a visual basic 6 exe. My VB6 project has a simple form with a text box on it. I have added a class to expose the Text Property and have added 1 method to write this property to the text box. The VB6 application is called AmegaWeb and the class is called Transfer. When I try to instantiate the object in my ASP script, I get the following error;

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string
/SendSVR.asp, line 37

The code in the script is as follows:

37   Set xfer = Server.CreateObject("AmegaWeb.Transfer")
38   xfer.Txt = strSEND
39   xfer.Exec
40   Response.Write "The result of this call was: " & Cstr(xfer.Result)
41  set xfer = nothing

I tried registering the AmegaWeb.exe to no avail. If this method is not possible, I need any solution available to be able to transfer a string of data from an ASP script to a visual basic 6 application. I tried using sockets and could not get that to work either.

Any help would be appreciated.

Thank You.
0
RonCangro
Asked:
RonCangro
  • 5
  • 4
  • 3
2 Solutions
 
anthonywjones66Commented:
The problem is that a VB6 Exe application with a form needs an interactive session to start in.  Does this exe really need to be an EXE.  Can you not use an ActiveX dll instead?



Anthony.
0
 
RonCangroAuthor Commented:
Yes, the VB6 application does need to be an exe. What exactly do you mean 'needs an interactive session to start in'? Eventually, I need to get the string data back to the exe application, but I am not opposed to going through another step if it would be easier. What I mean, is possibly creating a DLL that communicates with the ASP script and the VB6 application. But unless another method is used to communicate back to the VB6 app, I am in the same boat.

Ron
0
 
anthonywjones66Commented:
Where is the EXE program running?  On whose desktop does the form appear?

The ASP web site runs as a service, it isn't associated with any desktop.  If it were to launch an application that requires a user interface bad things can happen.

I'm not sure what to suggest really.  You can go for complex solutions such as:-

If the application MUST run with a UI then you could have the EXE running on the logged on console (or Remote Deskop Session) and have it register an object in the Running Object Table.  A separate utillity dll could then be used by ASP to retrieve the object with which you can communicate.  

or

Since you have access to the EXEs code you might consider breaking the Exe down and move the UI into an EXE and the logic into a DLL.  The DLL could be installed in COM+ and shared by both ASP and the UI.  This is the 'correct' solution from an architectural point of view.

On the other you can go for quick and dirty solutions such as:-

Have the EXE monitor a folder and have ASP create files in the folder.  (or message through a DB table.).

or

As it seems you may have already tried using some kind of sockets solution.

It really depends on how much time and effort you want to put in to the solution.

Also does the ASP need to wait for successful completion or returning data from the EXE?

Anthony.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
RonCangroAuthor Commented:
Currently I have the EXE running on the same computer as the Web Server. The GUI appears on my login. The ASP does not have to launch the EXE, it will always be running. The EXE is communicating with other programs via a sockets interface.

Method #1:  How would I have the EXE 'register an object in the Running Object Table'? I am not familiar with this. How would the separate utility DLL communicate to the EXE?

Method #2: I assume in this method, I create a DLL that has the object that will do the transfer from the ASP to EXE. However, I think there is a drawback; I require the EXE to be notified asyncronously when a button is pressed from the ASP. Could I accomplish that by continously polling the DLL to see if it has data from the ASP? Also, I am not sure how to install the DLL in COM+ (is that just registering it via regsvr32?).

Method #3: If you could give me some insight on the sockets solution, I may be able to use it. Every time I try to connect to the socket on the EXE, the status of the socket remains 'connecting' it never gets to 'connected'. if I put it into a loop waiting for the 'connected' status it gets hung up.

Method #4: Having the EXE monitor a folder is a last resort. I just think there has to be a better solution. Maybe an XML message via SOAP or something like that. I just don't have the experience to know.

Maybe you could suggest some sample code that I could try out. By the way, the ASP doesn not have to wait for completion and is not expecting any data from the EXE. This is a project that needs completion quickly so I am willing to put in as much effort as is needed.
0
 
anthonywjones66Commented:
Method #1:  Let's shelve that one because it is quite heavy.
Method #2:  I was proposing something far more drastic. The break of the EXE into components such that the ASP not longer had to communicate with a UI bearing EXE but with COM+ app that did all the real work.

Method #3:  Since you already have this in place in the EXE this would seem to be the most logical solution.  Can you show some code you were using?

Method #4:  Since you only need asynchronous access this is not such a bad option and is more robust than any of the others.   You don't need to burden yourself with SOAP etc.  just a simple XML format containing what you need will do.

Anthony.
0
 
RonCangroAuthor Commented:
The following is the ASP code I was using for Method #3 Socket Connection:

' Set up the Socket
set wsock = server.createobject("MSWinsock.Winsock")
wsock.remoteport=1111
wsock.remotehost=strPath   ' Retrieved from an INI file
wsock.close
wsock.connect
' Also tried putting a loop here to wait for sckConnected (7)
if wsock.state=sckConnected then
  'Send Data to EXE
  SvrMsg = "00147,1=Indoor Temp N4,1.5"
  wsock.SendData SvrMsg
else
  ' Can't Connect
  Response.Write "Socket State: " & Cstr(wsock.state)
end if
wsock.close

On the VB side I added a socket control and initialized:
wsckWeb.LocalPort = 1111
wsckWeb.Listen
' Process data in DataArrival() Event

Could you suggest code for Method #4 XML message?
Would the less Drastic Method #2 (Just separate Transfer Object into DLL) work?

Ron
0
 
sk33v3Commented:
You said the socket hands on trying to connect. My  question is what are you passing in the variable strPath?
0
 
anthonywjones66Commented:
Wsock.remotehost = '127.0.0.1'

Ought to work on the same server but this is followed by:-

wsock.close ???

also you do handle the connect request and call accept in the EXE don't you?

Anthony.
0
 
sk33v3Commented:
Remember don't forget on your loop to take into account any errors that may occur. So try the loop below.

'' Set up the Socket
set wsock = server.createobject("MSWinsock.Winsock")
wsock.remoteport=1111
wsock.remotehost=strPath   ' Retrieved from an INI file
wsock.close
wsock.connect
' Also tried putting a loop here to wait for sckConnected (7)
do until wsock.state=7 or wsock.state=9
  '' we are waiting for the socket to connect(7) or Error out(9)
loop
  if wsock.state=sckConnected then
    'Send Data to EXE
    SvrMsg = "00147,1=Indoor Temp N4,1.5"
    wsock.SendData SvrMsg
  else
    ' Can't Connect
    Response.Write "Socket State: " & Cstr(wsock.state)
  end if

wsock.close

On the VB side I added a socket control and initialized:
wsckWeb.LocalPort = 1111
wsckWeb.Listen
' Process data in DataArrival() Event
0
 
RonCangroAuthor Commented:
I added the check for wsock.state=9 in my loop, and it still hangs. When I remove the loop I see a socket State: 6 from the response.write statement. It doesn't seem to be getting past the 'Connecting' state.

In the ConnectionRequest Event on the EXE I have the following Code:
    If wsckWeb.State <> sckClosed Then  wsckWeb.Close
    ' Accept the request with the requestID  parameter.
    wsckWeb.Accept requestID

Is there any other code I need in the EXE to Accept the Connection?
0
 
sk33v3Commented:
Well if the remote host doesn't resolve it can take a while for it to return unresolvable.
0
 
RonCangroAuthor Commented:
It has been a week and I have not got the answer I have been looking for. I am still unable to communicate from my ASP script to my Visual Basic Application. I have not been able to get the sockets interface to work, nor has there been enough information to get any other method to work. I am going to ask that this question be deleted and each person who responded be given 50 points.

Thank you, but I am no closer at solving this problem than I was when I first asked it.

Ron
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now