473,722 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM server being passed an instance of an interface

I am using a Pascal like language (Wealth-Lab) on W2K and call this server:

class HelloWorld:
_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestSer ver"
_public_methods _ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs _ = ['noCalls']

def __init__(self):
self.softspace = 1
self.noCalls = 0

def Hello(self, WL ): # WL is an instance of a interface class that
exists in the client
# In VB this would look like Public Sub Hello(ByVal objWL As
WealthLab.IWeal thLabAddOn3)
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())

if __name__=='__ma in__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(Hello World)

How do I get the instance of the interface to have its methods? The Python
Trace Collector gives me:

Object with win32trace dispatcher created (object=None)
in _GetIDsOfNames_ with '('Hello',)' and '2048'

in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at 0x331ea00>)
Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283,
in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288,
in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
AttributeError: 'PyIDispatch' object has no attribute 'BarCount'
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
129, in _Invoke_
return DispatcherBase. _Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
42, in _Invoke_
self._HandleExc eption_()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
107, in _HandleExceptio n_
reraise()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283,
in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288,
in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
exceptions.Attr ibuteError: 'PyIDispatch' object has no attribute 'BarCount'
in _Invoke_ with 0 1024 2 ()
in _Invoke_ with 0 1024 2 ()
Jul 18 '05 #1
2 4591
You ought to be able to do
win32com.client .Dispatch(WL)
to get a usable com object.
hth
Roger

"Phil" <pr******@san.r r.com> wrote in message
news:rX******** *******@twister .socal.rr.com.. .
I am using a Pascal like language (Wealth-Lab) on W2K and call this server:
class HelloWorld:
_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestSer ver"
_public_methods _ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs _ = ['noCalls']

def __init__(self):
self.softspace = 1
self.noCalls = 0

def Hello(self, WL ): # WL is an instance of a interface class that
exists in the client
# In VB this would look like Public Sub Hello(ByVal objWL As
WealthLab.IWeal thLabAddOn3)
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())

if __name__=='__ma in__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(Hello World)

How do I get the instance of the interface to have its methods? The Python Trace Collector gives me:

Object with win32trace dispatcher created (object=None)
in _GetIDsOfNames_ with '('Hello',)' and '2048'

in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at 0x331ea00>) Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283, in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288, in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None) File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550, in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
AttributeError: 'PyIDispatch' object has no attribute 'BarCount'
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
129, in _Invoke_
return DispatcherBase. _Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
42, in _Invoke_
self._HandleExc eption_()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
107, in _HandleExceptio n_
reraise()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283, in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288, in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None) File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550, in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
exceptions.Attr ibuteError: 'PyIDispatch' object has no attribute 'BarCount' in _Invoke_ with 0 1024 2 ()
in _Invoke_ with 0 1024 2 ()

Jul 18 '05 #2
Hi Roger,

Thanks for the help. So now the program looks like:

import win32com.client

class HelloWorld:

_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"

_reg_desc_ = "Python Test COM Server"

_reg_progid_ = "Python.TestSer ver"

_public_methods _ = ['Hello']

_public_attrs_ = ['softspace', 'noCalls']

_readonly_attrs _ = ['noCalls']

def __init__(self):

self.softspace = 1

self.noCalls = 0

def Hello(self, WL ):

# In VB this looks like Public Sub Hello(ByVal objWL As
WealthLab.IWeal thLabAddOn3)

WL = win32com.client .Dispatch(WL)

self.noCalls = self.noCalls + 1

# insert "softspace" number of spaces

return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
if __name__=='__ma in__':

import win32com.server .register

win32com.server .register.UseCo mmandLine(Hello World)

The Python Trace Collector gives me:

Object with win32trace dispatcher created (object=None)

in _GetIDsOfNames_ with '('Hello',)' and '2048'

in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3d91824 with obj at 0x32eea00>)

Traceback (most recent call last):

File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 40,
in _Invoke_

return self.policy._In voke_(dispid, lcid, wFlags, args)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283, in
_Invoke_

return self._invoke_(d ispid, lcid, wFlags, args)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288, in
_invoke_

return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550, in
_invokeex_

return func(*args)

File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello

return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())

File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py", line 489,
in __getattr__

raise AttributeError, "%s.%s" % (self._username _, attr)

AttributeError: <unknown>.BarCo unt

pythoncom error: Python error invoking COM method.

Traceback (most recent call last):

File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
129, in _Invoke_

return DispatcherBase. _Invoke_(self, dispid, lcid, wFlags, args)

File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 42,
in _Invoke_

self._HandleExc eption_()

File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line
107, in _HandleExceptio n_

reraise()

File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 40,
in _Invoke_

return self.policy._In voke_(dispid, lcid, wFlags, args)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 283, in
_Invoke_

return self._invoke_(d ispid, lcid, wFlags, args)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 288, in
_invoke_

return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None, None)

File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line 550, in
_invokeex_

return func(*args)

File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello

return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())

File "C:\Python23\Li b\site-packages\win32c om\client\dynam ic.py", line 489,
in __getattr__

raise AttributeError, "%s.%s" % (self._username _, attr)

exceptions.Attr ibuteError: <unknown>.BarCo unt

in _Invoke_ with 0 1024 2 ()

in _Invoke_ with 0 1024 2 ()
"Roger Upole" <ru****@hotmail .com> wrote in message
news:40******** @127.0.0.1...
You ought to be able to do
win32com.client .Dispatch(WL)
to get a usable com object.
hth
Roger

"Phil" <pr******@san.r r.com> wrote in message
news:rX******** *******@twister .socal.rr.com.. .
I am using a Pascal like language (Wealth-Lab) on W2K and call this

server:

class HelloWorld:
_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestSer ver"
_public_methods _ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs _ = ['noCalls']

def __init__(self):
self.softspace = 1
self.noCalls = 0

def Hello(self, WL ): # WL is an instance of a interface class that
exists in the client
# In VB this would look like Public Sub Hello(ByVal objWL As
WealthLab.IWeal thLabAddOn3)
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())

if __name__=='__ma in__':
import win32com.server .register
win32com.server .register.UseCo mmandLine(Hello World)

How do I get the instance of the interface to have its methods? The

Python
Trace Collector gives me:

Object with win32trace dispatcher created (object=None)
in _GetIDsOfNames_ with '('Hello',)' and '2048'

in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at

0x331ea00>)
Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

283,
in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

288,
in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None,

None)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
AttributeError: 'PyIDispatch' object has no attribute 'BarCount'
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 129, in _Invoke_
return DispatcherBase. _Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 42, in _Invoke_
self._HandleExc eption_()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 107, in _HandleExceptio n_
reraise()
File "C:\Python23\Li b\site-packages\win32c om\server\dispa tcher.py", line 40, in _Invoke_
return self.policy._In voke_(dispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

283,
in _Invoke_
return self._invoke_(d ispid, lcid, wFlags, args)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

288,
in _invoke_
return S_OK, -1, self._invokeex_ (dispid, lcid, wFlags, args, None,

None)
File "C:\Python23\Li b\site-packages\win32c om\server\polic y.py", line

550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\ COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCall s) +
str(WL.BarCount ())
exceptions.Attr ibuteError: 'PyIDispatch' object has no attribute

'BarCount'
in _Invoke_ with 0 1024 2 ()
in _Invoke_ with 0 1024 2 ()


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
469
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program architecture into .Net -- not looking to do it at this time, just to understand how I would achieve it. In the old environment, we had two classes, a client and a server class, that managed a data object. The server object knew how to interface with the...
24
2620
by: ALI-R | last post by:
Hi All, First of all I think this is gonna be one of those threads :-) since I have bunch of questions which make this very controversial:-0) Ok,Let's see: I was reading an article that When you pass a Value-Type to method call ,Boxing and Unboxing would happen,Consider the following snippet: int a=1355; myMethod(a); ......
3
1818
by: znappa | last post by:
Hi. I would like to create an instance of a COM server from C# code. I now use the System.Runtime.InteropServices.Marshal.GetActiveObject() function to get the running instance (but this implies that there is an instance running). But I would like to check (at the start of my code) wether there is a running instance and if not, start one. I'm not to familiar with COM, so "best practise" hints would be nice!
6
4669
by: FS Liu | last post by:
Hi, In my current ATL server project, I have to parse the input in the client application's request to find out the different combination of parameters, instead of using SOAP. For this reason, I am not using ATL server web service project. On client side, I use POST to send XML to web server. I know I should use ISAXXMLReader in the server program. I also know that the parser can be used for many different handlers in the DLL. I found...
8
3117
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string parameters that should not be exposed. Each user is associated with a school, and should see only that school's data. When the user logs in, I retrieve the SchoolID associated with that user, and that SchoolID is used as a parameter in all stored...
2
4922
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The problem is that every time that I receive update to tree from the remote process,
2
11059
by: Ma³y Piotruœ | last post by:
Hello, (sorry for my English...) Could you help me please with installing SQL Servera 2005 Express Edition. I downloaded files: SQLEXPR.EXE - Microsoft SQL Server 2005 Express Edition SSEUtilSetup.EXE - SQL Server Express Utility SqlServer2K5_BOL_Dec2005.msi - Books Online December 2005 and I tried to run them sequentially. After installing SQLEXPR.EXE
0
3920
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
1
15216
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they can no longer connect to the domain controller. Ping resolves the domain controllers name to the correct ip nslookup finds the ip but can not resolve the name. When I attempt to log on to a machine on the domain it takes around twenty minutes...
0
9383
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2601
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.