You are not logged in.

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

1

Monday, January 18th 2010, 2:56pm

Jacob's changed and I can't figure it out

G'day everyone

Last year I wrote a demo showing how to call WScript.Network from Jabaco using Jacob. That was using Jacob 1.5. Now there's a Jacob 1.7 and I'm having a hard time figuring out how to get the same bit of code to work. This issue was pointed out by a someone commenting on the blog posting.

Quoted

Hallo Bruce,
Thank You for the Your article. I've tested the program (Windows 7, Jacobo 1.5.2, path to jacob.jar added to classpath, jacob.dll in c:\widows\system32) and got the the error
"Converting 'java/lang/Object' to 'com/jacob/com/Dispatch' not possible!"
in line Set dShell = oShell.getObject().
How do I cast oShell.getObject() to Dispatch type? Or is there something I'm missing?

Kind regards,
Bruce.

P.S. Here's the original code

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Public Sub main(ByJava args() As String)
   Dim myArgs() As String
   myArgs = args
   Dim oShell As ActiveXComponent
   'ActiveXComponent is exported by JACOB and referenced in the IDE
   '(yes, there’s an IDE, and it’s pretty good too) 
   Set oShell = New ActiveXComponent("WScript.Network")
   Dim a As String
   Dim b As String
   Dim c As String
   Dim dShell As Dispatch
   'Dispatch also part of JACOB. Nice that it uses the standard jargon
   Set dShell = oShell.getObject()
   a = Dispatch.call(dShell,"UserDomain")
   b = Dispatch.call(dShell,"ComputerName")
   c = Dispatch.call(dShell,"UserName")
   MsgBox (a & ", " & b & ", " & c)
   comthread.Release()
End Sub

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Monday, January 18th 2010, 3:40pm

Hi Bruce,
have you tried an explicit Cast()?

Jabaco Source

1
2
3
4
5
dShell = Cast(oShell.getObject(), Dispatch)

or

dShell = Cast(oShell.getObject(), com#jacob#com#Dispatch)


Notice that "Set" is not necessary in Janaco to assign object values.
Type "Object" should be compatible to any object in assignments without casting.
Well, I haven't got a better hint for you.

Greetings

A1880

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

3

Monday, January 18th 2010, 4:16pm

Hmmm ... interesting.

Quoted

#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77d66545, pid=5976, tid=6140
#
# JRE version: 6.0_17-b04
# Java VM: Java HotSpot(TM) Client VM (14.3-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x36545]
#
# An error report file with more information is saved as:
# J:\jacob\hs_err_pid5976.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
axtens has attached the following file:

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Monday, January 18th 2010, 4:48pm

Looks like a crash in the middle of Jacob.

Happy digging!

A1880

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

5

Tuesday, January 19th 2010, 2:48am

Yep, looks like it's time to talk to the Jacob folk themselves. :S

Hardo

Beginner

Posts: 5

Date of registration: Jan 19th 2010

  • Send private message

6

Tuesday, January 19th 2010, 8:29pm

Jacob

Hi Bruce,
now I'm in the Jabaco-Community. Your Code ist working now. I've downloaded jacob from here.
Regards Hardo.

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

7

Wednesday, January 20th 2010, 5:31am

Viele dank, Hardo

Let us say for now that my code works for Jacob 1.15-M3 as found on http://sourceforge.net/projects/jacob-project/

If I get it working with subsequent Jacobs, I let everyone know.

Kind regards,
Bruce.

Rate this thread
WoltLab Burning Board