- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to write a com client to test a server I wrote. However I am stuck at the first step. I am following the exampke VFADDER, where the geenrated module has some data types defined (CLSID,IID etc) which are then used in the main VFADDER to feed to COMCREATEOBJBYGUID.
The module wizd ran ok but my generated module does not have these guid definitions, it starts with CONTAINS then the wrapper shells for the automation methods, but no GUID type def'ns.
how can I create an instance of the object to call its methods?
better yet:
Where can I find an example of an automation client in CVF?
Any help will be appreciated.
Tim
The module wizd ran ok but my generated module does not have these guid definitions, it starts with CONTAINS then the wrapper shells for the automation methods, but no GUID type def'ns.
how can I create an instance of the object to call its methods?
better yet:
Where can I find an example of an automation client in CVF?
Any help will be appreciated.
Tim
Link Copied
13 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Tim,
There are 2 automation client samples on the kit under SamplesAdvancedCOM, Autodice and DSBuild. It is easiest to use the Prog-id rather than the CLSID when calling COMCreateObject for an Automation client. That automatically returns the IDispatch interface which is what you need for an Automation client. You can use the CLSID interface and ask specifically for IID_IDispatch (defined in the DFCOM module). I think earlier versions of the Module wizard did not generate CLSIDs when you selected Automation interfaces - but now id does.
Leo
There are 2 automation client samples on the kit under SamplesAdvancedCOM, Autodice and DSBuild. It is easiest to use the Prog-id rather than the CLSID when calling COMCreateObject for an Automation client. That automatically returns the IDispatch interface which is what you need for an Automation client. You can use the CLSID interface and ask specifically for IID_IDispatch (defined in the DFCOM module). I think earlier versions of the Module wizard did not generate CLSIDs when you selected Automation interfaces - but now id does.
Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see that Autodice does not call comcreateobjbyGUID. So I can follow that example(and let you know). However, it is not clear from your msg if my cvf 6.6 module wizd should or should NOT create the CLSIDs, I have installed v 6.6 by upgrade but how do I find out if the modwiz is the latest ver.?
Thanks.
Tim
Thanks.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
P.S.
Following the recipe of autodice when I compile the code with calls to the wrappers for the com server (tiself written in CVF6.6) I get:
Warning: DEC$ ATTRIBUTES DLLIMPORT is ignored for non-external procedure. [HEDGEHOG_KENT1_SETPARAMETERS]
I cannot decipher this.
and probably as the result, the routine returns an error in status=0x80020005
if it means anything that is.
Any ideas?
THanks, Tim
Following the recipe of autodice when I compile the code with calls to the wrappers for the com server (tiself written in CVF6.6) I get:
Warning: DEC$ ATTRIBUTES DLLIMPORT is ignored for non-external procedure. [HEDGEHOG_KENT1_SETPARAMETERS]
I cannot decipher this.
and probably as the result, the routine returns an error in status=0x80020005
if it means anything that is.
Any ideas?
THanks, Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>; I have installed v 6.6 by upgrade but how do I find out if the modwiz is the latest ver.?
V6.6 is the latest version. I believe it should create the CLSID parameter.
> I get: Warning: DEC$ ATTRIBUTES DLLIMPORT is ignored for non-external procedure.
You can ignore the warning. This is a new compiler message complaining about the attribute that the wizard generates for use in a DLL. If you are not building a DLL, you'll see the warning. In the future, the wizard will have the option to not generate the attribute statements.
> and probably as the result, the routine returns an error in status=0x80020005 if it means anything that is.
The run-time error has nothing to do with the compiler warning. You can look up the status codes using the Error Lookup tool in the VF program group. For this error status the text of the message is "Type mismatch". This usually means that the system Automation support was unable to convert one of the call arguments into the data type expected by the server.
Leo
V6.6 is the latest version. I believe it should create the CLSID parameter.
> I get: Warning: DEC$ ATTRIBUTES DLLIMPORT is ignored for non-external procedure.
You can ignore the warning. This is a new compiler message complaining about the attribute that the wizard generates for use in a DLL. If you are not building a DLL, you'll see the warning. In the future, the wizard will have the option to not generate the attribute statements.
> and probably as the result, the routine returns an error in status=0x80020005 if it means anything that is.
The run-time error has nothing to do with the compiler warning. You can look up the status codes using the Error Lookup tool in the VF program group. For this error status the text of the message is "Type mismatch". This usually means that the system Automation support was unable to convert one of the call arguments into the data type expected by the server.
Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Leo,
1. I can assure you that the generated module does NOT have the CLSID or any other parameters defined. It goes from "implicit-none" to "contains". Are you sure the new ver. is suppsed to do the GUIDs?
I really get uneasy thinking that the compiler is not doing certain things right.
2. The type mismatch was due to a var declared as Int(1) in the server which then showed up in the wrapper module as "character"!! It seems that when writing a server, choosing anything other than types that have direct counterparts in C is not a good idea. What do you think?
3. I had hoped that by writing a cvf client I can step into the cvf server to debug it. But now realize that it is not so obious. How can this be done?
4. What is the general fucntion of the module ADOBJECTS? does it have anyting to do with ADO ??
Thanks for your help.
Tim
1. I can assure you that the generated module does NOT have the CLSID or any other parameters defined. It goes from "implicit-none" to "contains". Are you sure the new ver. is suppsed to do the GUIDs?
I really get uneasy thinking that the compiler is not doing certain things right.
2. The type mismatch was due to a var declared as Int(1) in the server which then showed up in the wrapper module as "character"!! It seems that when writing a server, choosing anything other than types that have direct counterparts in C is not a good idea. What do you think?
3. I had hoped that by writing a cvf client I can step into the cvf server to debug it. But now realize that it is not so obious. How can this be done?
4. What is the general fucntion of the module ADOBJECTS? does it have anyting to do with ADO ??
Thanks for your help.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
p.s.
Also
5. A function in the server is supposed to return the last error ( as character(*)) bu then when called it returns blank. This happens both in a cvf AND a vba client. I've tried specifying the text in the server ending in 'C and //char(0) to no avail.
Any ideas?
Also
5. A function in the server is supposed to return the last error ( as character(*)) bu then when called it returns blank. This happens both in a cvf AND a vba client. I've tried specifying the text in the server ending in 'C and //char(0) to no avail.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> 1. I can assure you that the generated module does NOT have the CLSID or any other parameters defined. It goes from "implicit-none" to "contains". Are you sure the new ver. is suppsed to do the GUIDs? I really get uneasy thinking that the compiler is not doing certain things right.
I believe you, but I don't know why the wizard didn't generate a CLSID.
>2. The type mismatch was due to a var declared as Int(1) in the server which then showed up in the wrapper module as "character"!! It seems that when writing a server, choosing anything other than types that have direct counterparts in C is not a good idea. What do you think?
INT(1) was not among the original set of Automation data types and is not yet fully supported by the wizard. It is best tio use INT(2) if you have a choice, or you could modify the module generated by the wizard.
>3. I had hoped that by writing a cvf client I can step into the cvf server to debug it. But now realize that it is not so obious. How can this be done?
Usually, you can just step into it. But if that is not working, the best place to set breakpoints in your server is in the "interface-name".f90 file. After the "contains" statement are the routines called which are the first entry points for methods in the server. You can look at the arguments to see exactly what is being passed to a method, and you can single step from there to see what is happening.
>4. What is the general fucntion of the module ADOBJECTS? does it have anyting to do with ADO ??
Nothing to do with Microsoft ADO. In the Autodice sample it stands for "AutoDice Objects". It is a module containing "global" variables (e.g. the object identifiers (pointers)) and routines.
>p.s. Also 5. A function in the server is supposed to return the last error ( as character(*)) bu then when called it returns blank. This happens both in a cvf AND a vba client. I've tried specifying the text in the server ending in 'C and //char(0) to no avail.
I'd need more info to help on that. Maybe you could post the IDL file from your server and the Fortran routine that implements the method.
Leo
I believe you, but I don't know why the wizard didn't generate a CLSID.
>2. The type mismatch was due to a var declared as Int(1) in the server which then showed up in the wrapper module as "character"!! It seems that when writing a server, choosing anything other than types that have direct counterparts in C is not a good idea. What do you think?
INT(1) was not among the original set of Automation data types and is not yet fully supported by the wizard. It is best tio use INT(2) if you have a choice, or you could modify the module generated by the wizard.
>3. I had hoped that by writing a cvf client I can step into the cvf server to debug it. But now realize that it is not so obious. How can this be done?
Usually, you can just step into it. But if that is not working, the best place to set breakpoints in your server is in the "interface-name".f90 file. After the "contains" statement are the routines called which are the first entry points for methods in the server. You can look at the arguments to see exactly what is being passed to a method, and you can single step from there to see what is happening.
>4. What is the general fucntion of the module ADOBJECTS? does it have anyting to do with ADO ??
Nothing to do with Microsoft ADO. In the Autodice sample it stands for "AutoDice Objects". It is a module containing "global" variables (e.g. the object identifiers (pointers)) and routines.
>p.s. Also 5. A function in the server is supposed to return the last error ( as character(*)) bu then when called it returns blank. This happens both in a cvf AND a vba client. I've tried specifying the text in the server ending in 'C and //char(0) to no avail.
I'd need more info to help on that. Maybe you could post the IDL file from your server and the Fortran routine that implements the method.
Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Leo,
Thanks for your reply.
Follow ups:
1. Debugging the server: duhh, I think my problem with debugging has to do with the fact that the server and client are in separate projects. I had in mind the idea that the client with a main has no place in a DLL type project. still not clear if it will work. Am I even on the right track?
2.ADOBJECTS: The reason I ask is that the calls to Init/ReleaseOBJECTS are in that module. Not being able to follow the VFADDERsample due to lack of CLSID parameters, I somehow thought these calls are needed to initiate an Automation object...are they? or are they specific to excel and autodice.
3. blank text passing: I have posted two zipped files at:
www.rahzan.com/piposts/server.zip
and
www.rahzan.com/piposts/client.zip
they contain the full server and the sample client projects which shows the text being passed as blank only, the missing CLSID we discussed, as well as the newly discovered "problem" below.
4. array shape mismatch: A server method requires 2d arrays. This method works fine as tested from access/vba however the mod-wizd wrapper stipulates 1d arrays. This therefore halts compilation with 2d arrays as args to this method. I tried calling it with 1d arrays thinking that I should simply play along and pass arrays in a column major way (which is a pain in the shoes for high ranks) it compiles but still the method fails with a nondescript error.
Any help will be much appreciated.
Tim
tsh@rahzan.com
Thanks for your reply.
Follow ups:
1. Debugging the server: duhh, I think my problem with debugging has to do with the fact that the server and client are in separate projects. I had in mind the idea that the client with a main has no place in a DLL type project. still not clear if it will work. Am I even on the right track?
2.ADOBJECTS: The reason I ask is that the calls to Init/ReleaseOBJECTS are in that module. Not being able to follow the VFADDERsample due to lack of CLSID parameters, I somehow thought these calls are needed to initiate an Automation object...are they? or are they specific to excel and autodice.
3. blank text passing: I have posted two zipped files at:
www.rahzan.com/piposts/server.zip
and
www.rahzan.com/piposts/client.zip
they contain the full server and the sample client projects which shows the text being passed as blank only, the missing CLSID we discussed, as well as the newly discovered "problem" below.
4. array shape mismatch: A server method requires 2d arrays. This method works fine as tested from access/vba however the mod-wizd wrapper stipulates 1d arrays. This therefore halts compilation with 2d arrays as args to this method. I tried calling it with 1d arrays thinking that I should simply play along and pass arrays in a column major way (which is a pain in the shoes for high ranks) it compiles but still the method fails with a nondescript error.
Any help will be much appreciated.
Tim
tsh@rahzan.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>1. Debugging the server: duhh, I think my problem with debugging has to do with the fact that the server and client are in separate projects. I had in mind the idea that the client with a main has no place in a DLL type project. still not clear if it will work. Am I even on the right track?
You debug a DLL COM Server in the same way that you debug any other DLL. See the recent question in this forum.
>2.ADOBJECTS: The reason I ask is that the calls to Init/ReleaseOBJECTS are in that module. Not being able to follow the VFADDERsample due to lack of CLSID parameters, I somehow thought these calls are needed to initiate an Automation object...are they? or are they specific to excel and autodice.
ADOBJECTS itself is specific to Autodice. The concept of what it is doing is not. For your test application, the equivalent to ADOBJECTS should look like:
>3. blank text passing: I have posted two zipped files at: www.rahzan.com/piposts/server.zip and www.rahzan.com/piposts/client.zip
they contain the full server and the sample client projects which shows the text being passed as blank only, the missing CLSID we discussed, as well as the newly discovered "problem" below.
It looks like the missing CLSID is because you are choosing the wrong option in the Module Wizard. You should choose "Type Library containing Automation information" and not "Automation object". The "Automation Object" choice is pretty much obsolete at this point and will be removed from the wizard in the future.
For the blank text problem, I suggest that you change the lastError argument to be Intent Out, and a Return value. VB seems to do strange things with Intent InOut arguments.
>4. array shape mismatch: A server method requires 2d arrays. This method works fine as tested from access/vba however the mod-wizd wrapper stipulates 1d arrays. This therefore halts compilation with 2d arrays as args to this method. I tried calling it with 1d arrays thinking that I should simply play along and pass arrays in a column major way (which is a pain in the shoes for high ranks) it compiles but still the method fails with a nondescript error.
This is a restriction in the DFAUTO routines - they only handle single dimension arrays.
Leo
You debug a DLL COM Server in the same way that you debug any other DLL. See the recent question in this forum.
>2.ADOBJECTS: The reason I ask is that the calls to Init/ReleaseOBJECTS are in that module. Not being able to follow the VFADDERsample due to lack of CLSID parameters, I somehow thought these calls are needed to initiate an Automation object...are they? or are they specific to excel and autodice.
ADOBJECTS itself is specific to Autodice. The concept of what it is doing is not. For your test application, the equivalent to ADOBJECTS should look like:
MODULE TESTOBJECTS IMPLICIT NONE ! Object Pointers integer(4) pKent1 !pointer to the application CONTAINS SUBROUTINE INITOBJECTS() pKent1 = 0 END SUBROUTINE SUBROUTINE RELEASEOBJECTS() USE DFCOM INTEGER*4 status IF (pKent1 /= 0) status = COMRELEASEOBJECT ( pKent1 ) END SUBROUTINE END MODULE
>3. blank text passing: I have posted two zipped files at: www.rahzan.com/piposts/server.zip and www.rahzan.com/piposts/client.zip
they contain the full server and the sample client projects which shows the text being passed as blank only, the missing CLSID we discussed, as well as the newly discovered "problem" below.
It looks like the missing CLSID is because you are choosing the wrong option in the Module Wizard. You should choose "Type Library containing Automation information" and not "Automation object". The "Automation Object" choice is pretty much obsolete at this point and will be removed from the wizard in the future.
For the blank text problem, I suggest that you change the lastError argument to be Intent Out, and a Return value. VB seems to do strange things with Intent InOut arguments.
>4. array shape mismatch: A server method requires 2d arrays. This method works fine as tested from access/vba however the mod-wizd wrapper stipulates 1d arrays. This therefore halts compilation with 2d arrays as args to this method. I tried calling it with 1d arrays thinking that I should simply play along and pass arrays in a column major way (which is a pain in the shoes for high ranks) it compiles but still the method fails with a nondescript error.
This is a restriction in the DFAUTO routines - they only handle single dimension arrays.
Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks again,
Just two more questions:
The doc does not really say what the "return value" check box does. Can you clarify it a little?
Things look ok except of course for the array shape problem which you say is the fault of dfauto. The 2d array seems to pass just fine into vba.
Any prospects for fixing this? or a manual work around?
Tim
Just two more questions:
The doc does not really say what the "return value" check box does. Can you clarify it a little?
Things look ok except of course for the array shape problem which you say is the fault of dfauto. The 2d array seems to pass just fine into vba.
Any prospects for fixing this? or a manual work around?
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The doc does not really say what the "return value" check box does. Can you clarify it a little?
"return value" is an Automation concept (originating with VB). Every COM method must return an HRESULT, so there is no way for a COM method to actually return a data value (in the Win32 calling standard sense...). Marking an argument as a "return value" means that if this method could return a value, this would be it. Why does this matter? The reason is that VB sees this setting and makes the argument look like a return value in its syntax. For example, with a method FOO and an argument BAR, if BAR is an InOut variable, the call would look like:
Object.FOO(BAR)
If BAR is marked as a return value, it must be Intent Out, and the VB call looks like:
BAR = Object.FOO()
Things look ok except of course for the array shape problem which you say is the fault of dfauto. The 2d array seems to pass just fine into vba.
Any prospects for fixing this? or a manual work around?
The VB client and the Fortran COM server should work just fine with the 2d array. It's the Module Wizard (and DFAUTO) that can't handle it. The Module Wizard won't be extended any time soon. A manual workaround may be possible, but I'd need to spend time thinking about it. Are you going to need VF clients to your server?
Leo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Is it then correct to assume that for any OUT intent in VB the return box should also be checked? If so, does this apply to other languages, cvf/c++? As I mentoied even the cvf client was returning blank before (I have not tried the intent out, etc w/ the cvf client).
2. No I really do not need the cvf client. I only wrote it to debug the com server which I have yet to learn to do. So eventho' the modwiz is at fault I still
Can NOT manually modify the wrapper routine to make the declaration into 2d, correct?
The problem is that if I can not get a cvf client working (I've somehow assumed) that I cannot debug the server. This is the only real sticking point.
Thanks, Tim
2. No I really do not need the cvf client. I only wrote it to debug the com server which I have yet to learn to do. So eventho' the modwiz is at fault I still
Can NOT manually modify the wrapper routine to make the declaration into 2d, correct?
The problem is that if I can not get a cvf client working (I've somehow assumed) that I cannot debug the server. This is the only real sticking point.
Thanks, Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>1. Is it then correct to assume that for any OUT intent in VB the return box should also be checked?
I believe that this is correct, but there can only be one return value per method. Here are some things that I learned while testing VB clients with Fortran COM servers (also in the Creating a COM Server chapter):
Here are some points to be aware of when writing a server that can be used with Visual Basic clients:
Use only the Automation-compatible data types (see Method and Property Data Types).
Arguments to a method can be passed ByVal, ByRef, or they can be the function return value.
An argument to be passed ByVal, must be defined with Intent set to In.
An argument to be passed ByRef, must be defined with Intent set to InOut.
A function return value must be defined with Intent set to Out. It must have the Return Value field checked. The argument must be the final argument of the method.
An array is always passed as a SafeArray ByRef. Therefore it must be defined with Intent set to InOut.
To use an argument of the Visual Basic Boolean data type, set the Fortran data type to LOGICAL(2) and set the Interface data type to VARIANT_BOOL.
>If so, does this apply to other languages, cvf/c++?
No, these are VB-specific restrictions.
> As I mentoied even the cvf client was returning blank before (I have not tried the intent out, etc w/ the cvf client).
Yes, but that was another issue. Try declaring your string argument as CHARACTER(len=80) rather than CHARACTER(len=*). You can edit the data type on the argument property sheet.
>2. No I really do not need the cvf client. I only wrote it to debug the com server which I have yet to learn to do. So eventho' the modwiz is at fault I still Can NOT manually modify the wrapper routine to make the declaration into 2d, correct?
It is possible that you could modify the wrapper routine, create the 2d SafeArray yourself, Call AUTOAddArg to add the SafeArray to the argument list (set the type argument to VT_R4 .or. VT_ARRAY - assuming REAL(4) data), but I haven't tried it.
Leo
I believe that this is correct, but there can only be one return value per method. Here are some things that I learned while testing VB clients with Fortran COM servers (also in the Creating a COM Server chapter):
Here are some points to be aware of when writing a server that can be used with Visual Basic clients:
Use only the Automation-compatible data types (see Method and Property Data Types).
Arguments to a method can be passed ByVal, ByRef, or they can be the function return value.
An argument to be passed ByVal, must be defined with Intent set to In.
An argument to be passed ByRef, must be defined with Intent set to InOut.
A function return value must be defined with Intent set to Out. It must have the Return Value field checked. The argument must be the final argument of the method.
An array is always passed as a SafeArray ByRef. Therefore it must be defined with Intent set to InOut.
To use an argument of the Visual Basic Boolean data type, set the Fortran data type to LOGICAL(2) and set the Interface data type to VARIANT_BOOL.
>If so, does this apply to other languages, cvf/c++?
No, these are VB-specific restrictions.
> As I mentoied even the cvf client was returning blank before (I have not tried the intent out, etc w/ the cvf client).
Yes, but that was another issue. Try declaring your string argument as CHARACTER(len=80) rather than CHARACTER(len=*). You can edit the data type on the argument property sheet.
>2. No I really do not need the cvf client. I only wrote it to debug the com server which I have yet to learn to do. So eventho' the modwiz is at fault I still Can NOT manually modify the wrapper routine to make the declaration into 2d, correct?
It is possible that you could modify the wrapper routine, create the 2d SafeArray yourself, Call AUTOAddArg to add the SafeArray to the argument list (set the type argument to VT_R4 .or. VT_ARRAY - assuming REAL(4) data), but I haven't tried it.
Leo
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page