<div>Hi Mark,</div>
<div> </div>
<div>Thanks for your reply. I changed the py2exe script as per your suggestion an was able to generate the dll instead of exe.</div>
<div>I was also able to register it using regsvr32 command at command prompt.</div>
<div> </div>
<div>Any idea , now how should start using the functionalities in this dll in a VB/C# application?</div>
<div> </div>
<div>Because CreateObject("Sample.lib") is throwing errors in the same old manner, even after the dll is registered</div>
<div><br><br> </div>
<div><span class="gmail_quote">On 1/9/08, <b class="gmail_sendername">Mark Hammond</b> <<a href="mailto:mhammond@skippinet.com.au">mhammond@skippinet.com.au</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I just answered this email on the py2exe list without being aware you also posted it here - the issue is almost certainly incorrect usage of "com_server" and "console" in the py2exe script.
<br><br>Mark<br>----<br><br>From: <a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a> [mailto:<a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a>] On Behalf Of Tejovathi P
<br>Sent: Tuesday, 8 January 2008 10:04 PM<br>To: Pramod P G; <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>Subject: Re: [python-win32] Regarding COM server and exe<br><br>Here is my sample COM server and py2exe setup file
<br><br>testCOM.py<br><br>import win32com.client<br>import os.path<br>import shutil<br>from win32api import Sleep<br>import string<br>import os<br>import sys<br>import pythoncom<br><br>class FirstEx:<br><br> _reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
<br> pythoncom.frozen = 1<br> if hasattr(sys, 'importers'):<br> # In the py2exe-packed version, specify the module.class<br> # to use. In the python script version, python is able<br> # to figure it out itself.
<br> _reg_class_spec_ = "__main__.FirstEx"<br> _reg_desc_ = "My first COM server"<br> _reg_progid_ = "SAMPLE.Lib"<br> _public_methods_ = ['init', 'Version']<br> _public_attrs_ = ['softspace', 'noCalls']
<br> _readonly_attrs_ = ['noCalls']<br> _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER<br><br> def __init__(self):<br> self.softspace = 1<br> self.noCalls = 0<br><br> def Version(self):<br>
self.noCalls = self.noCalls + 1<br> # insert "softspace" number of spaces<br> return "Version: 0.0.1"<br><br><br>if __name__=='__main__':<br> import sys<br> if hasattr(sys, 'importers'):
<br> # running as packed executable.<br> if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]:<br> # --register and --unregister work as usual<br> import win32com.server.register
<br> win32com.server.register.UseCommandLine(FirstEx)<br> else:<br> # start the server.<br> from win32com.server import localserver<br> localserver.main()<br> else:<br> import
win32com.server.register<br> win32com.server.register.UseCommandLine(FirstEx)<br>Here is my setup file:<br>#Start here<br>from distutils.core import setup<br>import py2exe<br>setup(options = {"py2exe": {"compressed": 1,
<br> "optimize": 2,<br> "ascii": 1,<br> "bundle_files": 1}},<br> zipfile = None,<br> com_server = ["win32com.servers.interp
"],<br> console = ["testCOM.py"])<br>#End here<br>Here is my VB code:<br>Sub subRoutine()<br>Dim connection As Object<br>Dim returnvalue1 As String<br>Dim returnvalue2 As String<br>Dim flag3 As Boolean<br>
Set connection = CreateObject("SAMPLE.Lib")<br>returnvalue1 = connection.Version()<br>MsgBox (returnvalue1)<br>End Sub<br>The non exe version of the COM server ie. directlly running the testCOM.py registers the library properly and
<br>in the VB application, the message box displays the version as 0.0.1.<br>But, after I create the EXE file using the setup.py file and run it, it registers the library.<br>When I run the VB application, it hangs at the line
<br>Set connection = CreateObject("SAMPLE.Lib")<br>and displays. " ACTIVEX cannot create the object"<br>Any suggestions please....<br><br>On 1/8/08, Tejovathi P <<a href="mailto:tejovathi.p@gmail.com">
tejovathi.p@gmail.com</a>> wrote:<br>I am trying to create the obj in VB in the same manner, ie<br><br>Set Obj = CreateObject("sample.lib")<br>Strangely, the non exe version of the COM server works fine and I am able to access the public functions in VB application.
<br><br>Problem comes with the EXE version of the COM server, VB application jus hangs while executing,<br> Set obj = CreateObject("sample.lib")<br><br><br><br>On 1/8/08, Pramod P G <<a href="mailto:pramodpg@aztecsoft.com">
pramodpg@aztecsoft.com</a> > wrote:<br>Hi,<br>Try out this statement<br><br>This might help U ☺<br><br> Set obj = CreateObject("sample.lib")<br><br>Thanks and regards,<br>Pramod P G<br><br>________________________________________
<br>From: <a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a> [mailto:<a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a>] On Behalf Of Tejovathi P<br>Sent: Tuesday, January 08, 2008 3:57 PM
<br>To: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>Subject: [python-win32] Regarding COM server and exe<br><br>Hi All,<br><br>I have a Python COM server. I need to deploy it on various sytems. When I run the COM server from
<br>python its showing an output " Registered : sample.lib"<br><br>If I try to use the COM obj from a VB client like:<br><br>obj = CreateObject("sample.lib")<br><br>Its working fine without any errors<br>
<br>Now I am trying to convert this COM server to an exe through py2exe and after I run the exe, I am<br>getting the same output " Registered : sample.lib"<br><br>But If I try to use the COM obj from a VB client like
<br><br>obj = CreateObject("sample.lib")<br><br>A console pops up saying " Registered : sample.lib" and VB application hangs there.<br>Its throwing a VB error that "ActiveX object cannot be created......etc etc"
<br><br>Any suggestions please.......<br><br>Regards,<br>Tejovathi<br><br>The information contained in, or attached to, this e-mail, contains confidential information and is intended solely for the use of the individual or entity to whom they are addressed and is subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email.
<br><br><a href="http://www.aztecsoft.com">www.aztecsoft.com</a><br><br><br><br></blockquote></div><br>