Re: [OT] VBScript return string runtime error

2010-11-29 Thread Mark Hurd
I've replicated your problem with a simple VB6 class.

I'm not sure of the actual cause but your fix is:

id = client.SendRequest((request))

because the working client.SendRequest(request)

is really

client.SendRequest (request)

or

Call client.SendRequest((request)).

The call corresponding to the original id = line Call
client.SendRequest(request)

or

   client.SendRequest request

fails with TypeMismatch for me.

I assume the problem is VBScript only deals with Objects most of the
time, and so doesn't like the original accurate type being passed to
the (correct) accurate type, but the () returns the object to Object,
which it doesn't mind passing anywhere.

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

On 28 November 2010 18:09, Greg Keogh g...@mira.net wrote:
 I’ve been running experiments for almost two hours solid now, making mock
 functions and passing different arguments and return types in all
 combinations I can think of. I’ve cleaned my environment, registered,
 unregistered, etc. Everything works perfectly in unit tests, only in the VBS
 file I find this specific failure rule:



 I cannot get a return value from a method call that has a COM object as an
 argument.



 Sadly, I can’t just pass primitive types as the arguments to the function,
 as it takes far too many and some are collections.



 I think I’ll give up and have a glass of wine.



 Greg


Re: [OT] VBScript return string runtime error

2010-11-29 Thread Jason Keats
I believe that wrapping a parameter in parentheses forces it to be
passed ByVal - even if you've coded ByRef.

And, in VBScript, everything is a Variant (not quite the same thing as
an Object) - so you may have to use CVar occasionally.

On Mon, Nov 29, 2010 at 8:32 PM, Mark Hurd markeh...@gmail.com wrote:
 I've replicated your problem with a simple VB6 class.

 I'm not sure of the actual cause but your fix is:

    id = client.SendRequest((request))

 because the working client.SendRequest(request)

 is really

    client.SendRequest (request)

 or

    Call client.SendRequest((request)).

 The call corresponding to the original id = line Call
 client.SendRequest(request)

 or

   client.SendRequest request

 fails with TypeMismatch for me.

 I assume the problem is VBScript only deals with Objects most of the
 time, and so doesn't like the original accurate type being passed to
 the (correct) accurate type, but the () returns the object to Object,
 which it doesn't mind passing anywhere.

 --
 Regards,
 Mark Hurd, B.Sc.(Ma.)(Hons.)

 On 28 November 2010 18:09, Greg Keogh g...@mira.net wrote:
 I’ve been running experiments for almost two hours solid now, making mock
 functions and passing different arguments and return types in all
 combinations I can think of. I’ve cleaned my environment, registered,
 unregistered, etc. Everything works perfectly in unit tests, only in the VBS
 file I find this specific failure rule:



 I cannot get a return value from a method call that has a COM object as an
 argument.



 Sadly, I can’t just pass primitive types as the arguments to the function,
 as it takes far too many and some are collections.



 I think I’ll give up and have a glass of wine.



 Greg



RE: [OT] VBScript return string runtime error

2010-11-29 Thread Greg Keogh
I've replicated your problem with a simple VB6 class.
I'm not sure of the actual cause but your fix is:
id = client.SendRequest((request))
(cut)

Mark, pardon my French, but holy shit! That works. Putting (()) around the
object argument sends it and gives me a string reply, which previously gave
me the runtime error.

I'd been searching for hours and never found any such syntax or clues
anywhere. Where did you get that trick?

Now I'm passed that hurdle I've reached the next one ... I'm getting Unable
to find assembly , which I know is a lie. In this case I'm passing a
string as an argument and getting back the same object that I'm passing in
my previous problem. So now I can send it, but not get it back. Some sites
hint at missing serializable attributes or incorrect COM attributes on the
interface or classes, but that doesn't seem likely so far. Oh well, I'll
keep slogging away and let you know if I find the answer.

http://stackoverflow.com/questions/1733087/unable-to-call-c-code-from-vbscri
pt-activex-error

Thanks heaps,
Greg



Re: [OT] VBScript return string runtime error

2010-11-29 Thread David Rhys Jones
Just as a side note.

The last time I developped a com interface in .net and used that object in
excel I had a hell of a lot of problems with versioning etc.

What I ended up doing, and it worked very well, was wrap the Com .net object
in a WSC windows script component. I don't know if they are stil usable in
windows 7, but they fixed no end of silly errors.  The bonus is you can
change the interface of the script object and it still retains the same
reference, making bug fixes a doddle.

Davy.


On Mon, Nov 29, 2010 at 12:29, Greg Keogh g...@mira.net wrote:

 I've replicated your problem with a simple VB6 class.
 I'm not sure of the actual cause but your fix is:
id = client.SendRequest((request))
 (cut)

 Mark, pardon my French, but holy shit! That works. Putting (()) around the
 object argument sends it and gives me a string reply, which previously gave
 me the runtime error.

 I'd been searching for hours and never found any such syntax or clues
 anywhere. Where did you get that trick?

 Now I'm passed that hurdle I've reached the next one ... I'm getting
 Unable
 to find assembly , which I know is a lie. In this case I'm passing a
 string as an argument and getting back the same object that I'm passing in
 my previous problem. So now I can send it, but not get it back. Some sites
 hint at missing serializable attributes or incorrect COM attributes on the
 interface or classes, but that doesn't seem likely so far. Oh well, I'll
 keep slogging away and let you know if I find the answer.


 http://stackoverflow.com/questions/1733087/unable-to-call-c-code-from-vbscri
 pt-activex-errorhttp://stackoverflow.com/questions/1733087/unable-to-call-c-code-from-vbscri%0Apt-activex-error

 Thanks heaps,
 Greg




Re: [OT] VBScript return string runtime error

2010-11-29 Thread Mark Hurd
On 29 November 2010 21:59, Greg Keogh g...@mira.net wrote:
snip

 I'd been searching for hours and never found any such syntax or clues
 anywhere. Where did you get that trick?

I've known putting brackets around an expression forces ByVal
semantics for a long time, but the key point here was the reminder
that this is VBScript and not VB.NET, so I knew the silent
difference between the working and non-working code.


 Thanks heaps,
 Greg

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)


Re: [OT] VBScript return string runtime error

2010-11-27 Thread djones147
Does this mean you are sending back an object?

request.Comment = Mock comment

 
request.Body = This is a mock body text

If it does is the object returned visible and compliant? 

Davy
-Original Message-
From: Greg Keogh g...@mira.net
Sender: ozdotnet-boun...@ozdotnet.com
Date: Sun, 28 Nov 2010 15:39:02 
To: 'ozDotNet'ozdotnet@ozdotnet.com
Reply-To: ozDotNet ozdotnet@ozdotnet.com
Subject: [OT] VBScript return string runtime error

Folks, I'm using some VBSCript to drive a COM visible library and check it's
working. But in the line in red below I get a runtime error. I'm just trying
to get a string id back from the SendRequest call. If I remove the id = 
before the call then it works.

 

What's crazy is that the previous DeleteRequest call returns a bool and it
works. So why can I get a bool back from one call but not a string from the
other call?

 

set client = WScript.CreateObject(Foobar.ComClient.Client)

WScript.Echo Created COM client
flag = client.DeleteRequest(SomeKey)
WScript.Echo Delete return =   flag
:
set request = WScript.CreateObject(Foobar.ComClient.Request)
request.Comment = Mock comment
request.Body = This is a mock body text
WScript.Echo Created request
:
id = client.SendRequest(request)
WScript.Echo Returned request Id =   id

 

Created COM client

Delete return = 0

Created request

vbstest.vbs(15, 1) Microsoft VBScript runtime error: Invalid procedure call
or argument: 'client.SendRequest'

 

Greg




RE: [OT] VBScript return string runtime error

2010-11-27 Thread Greg Keogh
Does this mean you are sending back an object?
request.Comment = Mock comment
request.Body = This is a mock body text
If it does is the object returned visible and compliant? 

 

No, 'request' is a COM object argument that I fill and send in the
SendRequest method. The method returns a string. It's the string that I
can't get back due to the runtime error. I made a unit test that performs
exactly the same calls as the VBS file it works perfectly. Now I have made
dummy methods to see how they go in the VBS file. The results are consistent
but I don't understand them.

 

string = Function()

string = Function(string)

Function(COMobject)

String = Function(COMobject)

 

Only the last one gives the runtime error. I've tried different argument
types. The rule is that I can't combine a return value with a COM object
argument.

 

Greg



Re: [OT] VBScript return string runtime error

2010-11-27 Thread djones147

I'm assuming that request is defined in the assembly that you are calling, so 
it's not .net that doesn't understand the object. 

Have you changed the signature of the assembly after you registered it? 
Unreg/rereg.  This includes reordering methods in the exposed interface. 

Other than that, the easiest solution is not to pass the object but call a 
method with simple types. 

Not much more I can think of at the mo.

Davy



-Original Message-
From: Greg Keogh g...@mira.net
Date: Sun, 28 Nov 2010 17:45:28 
To: djones...@gmail.com; 'ozDotNet'ozdotnet@ozdotnet.com
Subject: RE: [OT] VBScript return string runtime error

Does this mean you are sending back an object?
request.Comment = Mock comment
request.Body = This is a mock body text
If it does is the object returned visible and compliant? 

 

No, 'request' is a COM object argument that I fill and send in the
SendRequest method. The method returns a string. It's the string that I
can't get back due to the runtime error. I made a unit test that performs
exactly the same calls as the VBS file it works perfectly. Now I have made
dummy methods to see how they go in the VBS file. The results are consistent
but I don't understand them.

 

string = Function()

string = Function(string)

Function(COMobject)

String = Function(COMobject)

 

Only the last one gives the runtime error. I've tried different argument
types. The rule is that I can't combine a return value with a COM object
argument.

 

Greg




RE: [OT] VBScript return string runtime error

2010-11-27 Thread Greg Keogh
I've been running experiments for almost two hours solid now, making mock
functions and passing different arguments and return types in all
combinations I can think of. I've cleaned my environment, registered,
unregistered, etc. Everything works perfectly in unit tests, only in the VBS
file I find this specific failure rule:

 

I cannot get a return value from a method call that has a COM object as an
argument.

 

Sadly, I can't just pass primitive types as the arguments to the function,
as it takes far too many and some are collections.

 

I think I'll give up and have a glass of wine.

 

Greg