473,804 Members | 3,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM server and EXE

Hi All,

I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"

If I try to use the COM obj from a VB client like:

obj = CreateObject("s ample.lib")

Its working fine without any errors

Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"

But If I try to use the COM obj from a VB client like

obj = CreateObject("s ample.lib")

A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......et c etc"

Any suggestions please.......

Regards,
Tejovathi
Jan 8 '08 #1
2 2276
On Jan 8, 3:33*pm, Teja <tejovath...@gm ail.comwrote:
Hi All,

I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"

If I try to use the COM obj from a VB client like:

obj = CreateObject("s ample.lib")

Its working fine without any errors

Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"

But If I try to use the COM obj from a VB client like

obj = CreateObject("s ample.lib")

A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......et c etc"

Any suggestions please.......

Regards,
Tejovathi
Here is my sample COM server and py2exe setup file

testCOM.py

import win32com.client
import os.path
import shutil
from win32api import Sleep
import string
import os
import sys
import pythoncom

class FirstEx:

_reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
pythoncom.froze n = 1
if hasattr(sys, 'importers'):
# In the py2exe-packed version, specify the module.class
# to use. In the python script version, python is able
# to figure it out itself.
_reg_class_spec _ = "__main__.First Ex"
_reg_desc_ = "My first COM server"
_reg_progid_ = "SAMPLE.Lib "
_public_methods _ = ['init', 'Version']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs _ = ['noCalls']
_reg_clsctx_ = pythoncom.CLSCT X_LOCAL_SERVER

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

# insert "softspace" number of spaces
return "Version: 0.0.1"
if __name__=='__ma in__':
import sys
if hasattr(sys, 'importers'):
# running as packed executable.
if '--register' in sys.argv[1:] or '--unregister' in
sys.argv[1:]:
# --register and --unregister work as usual
import win32com.server .register
win32com.server .register.UseCo mmandLine(First Ex)
else:
# start the server.
from win32com.server import localserver
localserver.mai n()
else:
import win32com.server .register
win32com.server .register.UseCo mmandLine(First Ex)

Here is my setup file:

#Start here
from distutils.core import setup
import py2exe

setup(options = {"py2exe": {"compressed ": 1,
"optimize": 2,
"ascii": 1,
"bundle_fil es": 1}},
zipfile = None,
com_server = ["win32com.serve rs.interp"],
console = ["testCOM.py "])
#End here
Here is my VB code:

Sub subRoutine()
Dim connection As Object
Dim returnvalue1 As String
Dim returnvalue2 As String
Dim flag3 As Boolean

Set connection = CreateObject("S AMPLE.Lib")
returnvalue1 = connection.Vers ion()
MsgBox (returnvalue1)
End Sub
The non exe version of the COM server ie. directlly running the
testCOM.py registers the library properly and

in the VB application, the message box displays the version as 0.0.1.

But, after I create the EXE file using the setup.py file and run it,
it registers the library.

When I run the VB application, it hangs at the line

Set connection = CreateObject("S AMPLE.Lib")

and displays. " ACTIVEX cannot create the object"

Any suggestions please....
Jan 8 '08 #2
On 8 Jan, 11:04, Teja <tejovath...@gm ail.comwrote:
On Jan 8, 3:33 pm, Teja <tejovath...@gm ail.comwrote:
Hi All,
I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"
If I try to use the COM obj from a VB client like:
obj = CreateObject("s ample.lib")
Its working fine without any errors
Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"
But If I try to use the COM obj from a VB client like
obj = CreateObject("s ample.lib")
A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......et c etc"
Any suggestions please.......
Regards,
Tejovathi

Here is my sample COM server and py2exe setup file

testCOM.py

import win32com.client
import os.path
import shutil
from win32api import Sleep
import string
import os
import sys
import pythoncom

class FirstEx:

_reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
pythoncom.froze n = 1
if hasattr(sys, 'importers'):
# In the py2exe-packed version, specify the module.class
# to use. In the python script version, python is able
# to figure it out itself.
_reg_class_spec _ = "__main__.First Ex"
_reg_desc_ = "My first COM server"
_reg_progid_ = "SAMPLE.Lib "
_public_methods _ = ['init', 'Version']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs _ = ['noCalls']
_reg_clsctx_ = pythoncom.CLSCT X_LOCAL_SERVER

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

def Version(self):
self.noCalls = self.noCalls + 1

# insert "softspace" number of spaces
return "Version: 0.0.1"

if __name__=='__ma in__':
import sys
if hasattr(sys, 'importers'):
# running as packed executable.
if '--register' in sys.argv[1:] or '--unregister' in
sys.argv[1:]:
# --register and --unregister work as usual
import win32com.server .register
win32com.server .register.UseCo mmandLine(First Ex)
else:
# start the server.
from win32com.server import localserver
localserver.mai n()
else:
import win32com.server .register
win32com.server .register.UseCo mmandLine(First Ex)

Here is my setup file:

#Start here
from distutils.core import setup
import py2exe

setup(options = {"py2exe": {"compressed ": 1,
"optimize": 2,
"ascii": 1,
"bundle_fil es": 1}},
zipfile = None,
com_server = ["win32com.serve rs.interp"],
console = ["testCOM.py "])
#End here

Here is my VB code:

Sub subRoutine()
Dim connection As Object
Dim returnvalue1 As String
Dim returnvalue2 As String
Dim flag3 As Boolean

Set connection = CreateObject("S AMPLE.Lib")
returnvalue1 = connection.Vers ion()
MsgBox (returnvalue1)
End Sub

The non exe version of the COM server ie. directlly running the
testCOM.py registers the library properly and

in the VB application, the message box displays the version as 0.0.1.

But, after I create the EXE file using the setup.py file and run it,
it registers the library.

When I run the VB application, it hangs at the line

Set connection = CreateObject("S AMPLE.Lib")

and displays. " ACTIVEX cannot create the object"

Any suggestions please....
A quick suggestion (didn't read very carefully sorry).
Make sure you register it with --debug and use the pythonwin tools-
>trace collector debugging tool.
See if you get any joy. It may be you missed some vital library in
your py2exe
that causes a start-up time failure.

Giles
Jan 8 '08 #3

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

Similar topics

2
4604
by: Phil | last post by:
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.TestServer" _public_methods_ = _public_attrs_ = _readonly_attrs_ =
6
4461
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what I am currently doing: When I run sqlservr.exe I see the following: 2003-12-19 15:51:28.20 server Microsoft SQL Server 2000 - 8.00.760 (Intel X8 6)
9
669
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create a server group. I right click on the "SQL Server Group" and make a name of "TEST" and put in the subgroup of "SQL Server Group". Next, I try to register the "TEST" server group. I right click on the "TEST" server group and New Server Group...
0
2823
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: - Removing SQL server from 'Program Files' folder following an unsuccessful attempt to re-install, and entirely removing the registry entry 'HKEY_CURRENT_USER > SOFTWARE > Microsoft > MSSQLServer', as well as the corresponding entry under...
0
4550
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager Express Edition v1.3.2 Win, IBM Tivoli System Automation v1.2.0 Linux, IBM Tivoli Workload Scheduler Virtualized Data Centers v8.2 , other IBM Tivoli CDs, WEBSPHERE EVERYPLACE MOBILE PORTAL v5.0 - ALTIUM , other IBM WebSphere Business CDs...
2
8407
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
2
4932
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
6971
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
14
3050
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can anyone please help me with this as I want to install SQL server and also wouold be grateful, if you can suggest me any workaround to dealwith this problem.(Like should I install any new OS etc). Any help would be appreciated.
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7620
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
6853
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
5521
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
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
3
2991
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.