473,575 Members | 3,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot register dll created using "py2exe --com-dll"

I'm feeling quite dumb this morning.

I'm trying to build a COM server DLL using py2exe and it ain't working.

Here's what ain't working...

setup_dll.py based on py2exe sample:
"""from distutils.core import setup
import py2exe

setup(name="Mad eUpName Object Model",
scripts=['madeupname.app lication'],
output_base='ma deupname')
"""

Command line for building dll (N.B. python 2.3 as instructed):
"""c:\python23\ python madeupname/setup_dll.py py2exe --com-dll --excludes Tkinter"""

Command line for registering dll:
regsvr32 c:\pvcs\madeupn ame\model\dist\ application.dll

Result when I try to register dll:
"""DllRegisterS erver in c:\pvcs\madeupn ame\model\dist\ application.dll failed.
Return code was: 0x80040201
"""

The winerror.h entry for this says:
"""//
// MessageId: CO_E_FAILEDTOGE TSECCTX
//
// MessageText:
//
// Unable to obtain server's security context
//
#define CO_E_FAILEDTOGE TSECCTX _HRESULT_TYPEDE F_(0x80040201L)
"""

But I'm guessing that this is simply a way of saying the I haven't told
pythoncom (via py2exe) which classes to register. I'm looking at the
source and I am trying to work it out but failing :-(

I have tried an exe server, but this does not register either.

Any suggestions?

Also does anyone know what argument to use to get py2exe to build something
other than "applicatio n.[dll/exe]". I thought 'output_base' as an argument
to setup() would do it, but no joy.

If you folks can make me feel even more stupid by pointing out my
obvious mistake, that would make me happy. :-)

Thanks for reading,
Giles Brown
Jul 18 '05 #1
5 9094
Giles Brown wrote:
I'm feeling quite dumb this morning.

I'm trying to build a COM server DLL using py2exe and it ain't working.
Not too surprising seeing as it was checked in just days ago :)

Command line for registering dll:
regsvr32 c:\pvcs\madeupn ame\model\dist\ application.dll

Result when I try to register dll:
"""DllRegisterS erver in c:\pvcs\madeupn ame\model\dist\ application.dll failed.
Return code was: 0x80040201
"""
This generally just means that there was a Python exception. As regsvr
is a GUI app, the exception is lost. You may like to add "import
win32traceutil" at the top of your script (see win32traceutil. py for
details) - or if that fails, at the top of boot_com_server s.py.
I have tried an exe server, but this does not register either.
Try an EXE server build with the console flag set. This should allow
you to see the exception without redirecting error output.
Also does anyone know what argument to use to get py2exe to build something
other than "applicatio n.[dll/exe]". I thought 'output_base' as an argument
to setup() would do it, but no joy.


Can't recall - sorry.

Mark.

Jul 18 '05 #2
Err, I meant argv just isn't getting set :) It's early.
Jul 18 '05 #3

A fix that seems to work (at least it lets DllRegisterServ er succeed) is inserting
the following before the aforementioned line:

scriptDir = None
if hasattr(sys, 'argv'):
scriptDir = os.path.split(s ys.argv[0])[0]

This allows registration, but now when I try to instantiate one of the objects
defined in my dll from the interpreter, I get the following error:

Fatal Python error: PyThreadState_G et: no current thread

This also happens with the server example included. Do I have to use something
other than win32com.client .Dispatch to connect to an inproc server from a
dll? I think I've used it before to do the same thing with non-py2exe dlls.

Jordan
Jul 18 '05 #4
gi*********@hot mail.com (Giles Brown) wrote in message news:<57******* *************** ****@posting.go ogle.com>...
I'm feeling quite dumb this morning.


Next morning not quite so dumb. Finally got the dll to register so
I thought I'd post my findings for the record.

Mark was spot on (of course!) about the lost python exception. I
added
"import win32traceutil" into boot_com_server and low the traceback
showed in pythonwin.

I had omitted to mention that I am using win32com client inside the
dll,
so I added the necessary '--progids' (only "ADODB.Connecti on.2.1" as
it happens).

<aside>
Inside one of my modules I use the gencache.Ensure Module function.
"""#Microso ft ActiveX Data Objects 2.1 Library
# {00000201-0000-0010-8000-00AA006D2EA4}, lcid=0, major=2, minor=1
gencache.Ensure Module('{000002 01-0000-0010-8000-00AA006D2EA4}', 0, 2,
1)
"""
This function takes a CLSID (? I think). If I want to use this
specific
typelib based module, how do I determine what progid to give to py2exe
to ensure that this module is picked up? Or am I doing the wrong
thing?
</aside>

Then I found that my dll when run (for registration) was trying to
generate
an '__init__.py' in the equivalent of the gen_py folder. This was
failing
because it was looking for win32com.__gen_ path__ which is not set for
frozen code. To overcome this I added (something like) the following
code
to my module that was included the EnsureModule call.

if getattr(pythonc om, 'frozen', False):

import os
import win32com
import tempfile

# Assign (temporary) directory for gencache
# (tempfile.tempd ir is always 'None' so use TemporaryFile() ) :-(
win32com.__gen_ path__ = os.path.join(os .path.dirname(
tempfile.Tempor aryFile().name) , 'gencache')

Finally I was getting the "codec" problem. I tried '--packages
encodings' but
for some reason this did not seem to build encodings.__ini t__.pyc into
the
dll. This exhibited itself in the "no codec search functions
registered"
LookupError. Adding '--include encodings" fixed this. This lead (not
unreasonably) to a "unknown encoding: utf-8" LookupError which was
fixed by
added ",encodings.utf _8" to the command line.

The final working command line looked like this:
c:\python23\pyt hon madeupname/setup_dll.py py2exe --com-dll --include
encodings,encod ings.utf_8 --excludes Tkinter --progids
ADODB.Connectio n.2.1

Now I need to test the DLL :-)

Cheers and thanks,
Giles
Jul 18 '05 #5
ranjits
1 New Member
giles_brown@hot mail.com (Giles Brown) wrote in message news:<57de9986. 0307290052.688e 54c5@posting.go ogle.com>...[color=blue]
> I'm feeling quite dumb this morning.[/color]

Next morning not quite so dumb. Finally got the dll to register so
I thought I'd post my findings for the record.

Mark was spot on (of course!) about the lost python exception. I
added
"import win32traceutil" into boot_com_server and low the traceback
showed in pythonwin.

I had omitted to mention that I am using win32com client inside the
dll,
so I added the necessary '--progids' (only "ADODB.Connecti on.2.1" as
it happens).

<aside>
Inside one of my modules I use the gencache.Ensure Module function.
"""#Microso ft ActiveX Data Objects 2.1 Library
# {00000201-0000-0010-8000-00AA006D2EA4}, lcid=0, major=2, minor=1
gencache.Ensure Module('{000002 01-0000-0010-8000-00AA006D2EA4}', 0, 2,
1)
"""
This function takes a CLSID (? I think). If I want to use this
specific
typelib based module, how do I determine what progid to give to py2exe
to ensure that this module is picked up? Or am I doing the wrong
thing?
</aside>

Then I found that my dll when run (for registration) was trying to
generate
an '__init__.py' in the equivalent of the gen_py folder. This was
failing
because it was looking for win32com.__gen_ path__ which is not set for
frozen code. To overcome this I added (something like) the following
code
to my module that was included the EnsureModule call.

if getattr(pythonc om, 'frozen', False):

import os
import win32com
import tempfile

# Assign (temporary) directory for gencache
# (tempfile.tempd ir is always 'None' so use TemporaryFile() ) :-(
win32com.__gen_ path__ = os.path.join(os .path.dirname(
tempfile.Tempor aryFile().name) , 'gencache')

Finally I was getting the "codec" problem. I tried '--packages
encodings' but
for some reason this did not seem to build encodings.__ini t__.pyc into
the
dll. This exhibited itself in the "no codec search functions
registered"
LookupError. Adding '--include encodings" fixed this. This lead (not
unreasonably) to a "unknown encoding: utf-8" LookupError which was
fixed by
added ",encodings.utf _8" to the command line.

The final working command line looked like this:
c:\python23\pyt hon madeupname/setup_dll.py py2exe --com-dll --include
encodings,encod ings.utf_8 --excludes Tkinter --progids
ADODB.Connectio n.2.1

Now I need to test the DLL :-)

Cheers and thanks,
Giles

Hi All,

I am having a similar problem as this thread suggests but I am not being able to solve my problem. I wrote a simple COM server DLL and registered it successfully on my machine. I tested this DLL using a simple EXCEL/VBA script and that was successful too.
Now the problem began. I tried to register this dll on a friend's machine(this machine did not have python or py2exe installed) and I was getting this error -

---------------------------
RegSvr32
---------------------------
DllRegisterServ er in TestCOMServer2. dll failed.
Return code was: 0x80040201
---------------------------
OK
---------------------------

I tried to register this dll on another machine which had python and py2exe installed and there i successfully got it registered but when i tested the code using Excel/VBA i got the error "Catastroph ic Failure".

Does anyone have any idea why i am getting these different errors on different machines (all Win XP professional machines).

regards,
Ranjit
Feb 27 '06 #6

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

Similar topics

0
4700
by: Ben Jones | last post by:
Hi there, I am looking into the ease of implementing the localization/globalization features of .NET using C#. I have a test app which creates a ResourceManager and attempts to load a resource for a specified culture. I created the WinForm application in Visual Studio and added a default *fallback* resource to the main assembly. When I...
2
4277
by: Robert M. | last post by:
Information: Server A: SQL Server 2000 Enterprise Edition. OS is Windows 2003 Server Enterprise Edition. SQL Service pack is 3a. Member of domain ABCDomain. Server A is going to function as a Distributor. Location: New York. Server B: SQL Server 2000 Enterprise Edition. OS is Windows 2003 Server Standard Edition. SQL Service pack is...
6
2157
by: Vikram | last post by:
I have added some input elements on a page using javascript at client side. when i submit the page, i am unable to access the values of input elements created using request.form. Are elements created using javascript are available at the server? if not how can i do the above thing so that there values can be accessed. I dont want to...
0
1339
by: Andrew | last post by:
Hi, When I click on File > New > New Project on the VS.NET 2003 menu, I get the normal window asking me what type of project I would like to create. After choosing the ASP.NET Web Application, I click on "OK". I get an error message stating: "Microsoft Development Environment Object with program ID VsWizard.VsWizardEngine.7.1 cannot be...
4
7375
by: normb | last post by:
My name is Norm, I changed something that caused this problem, and I do not what it was. I also do not know how to debug this problem! The line where the crash occures is marked by an *. The windows form will not display in the designer. Please help!! // // Animal // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
0
3149
by: Pete Newman | last post by:
In running vs (vb ) .net 2005 and Sql 2005 On my form i have an oledbconnection, an oledbdataadapter and a dataset. when i try and do an update i get an error; 'Child list for field DebBacsfmDestAccs cannot be created' im at a loss as to how to resolve this .. i need help please code;
2
3360
by: Rob Dob | last post by:
Hi, I have several reports ( .rdl) that I created using report designer, how can I let the end user make modifications to the text in some of these reports. As I am unable to use Report Builder to modify reports ( .rdl ) created with Report designer, what are my options. is there a way I can embed the report designer within my c# winform...
6
7306
by: Sachin | last post by:
Hi All, I deployed an ASP.NET Web Service on Server1 and it worked fine. However when I deployed the same Web Service on Server2 I am getting the following error, The 'System.ServiceModel/ServiceHostingEnvironment' configuration section cannot be created. The Machin.config file is missing information. Verify that this configuration...
0
1334
by: Dhananjay | last post by:
Hi All, I want to develop one application in vb.net for exchange 2000. I tried to add one contact with the code snippet below. The same logic is there for appointment on Microsoft's site. (I added Microsoft CDO exchange library for 2000 & activex data object 2.5 reference to the project) Dim sURL As String sURL =...
0
1747
by: =?Utf-8?B?QXR1bCBSYW5l?= | last post by:
Hi, I am using datagridview when, I am assigning datasource to Datagridview i am gettin exception "Child list for field Region cannot be created." I am Assigning Collection as a datasource to the datagridview. AnnotationGrid.DataSource = XMLAnnotations; AnnotationGrid.DataMember = "Region"; and my grid has three coloumns ID, Area,...
0
7775
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...
1
7868
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...
0
8143
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...
0
6515
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5338
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...
0
3797
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2286
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
1
1382
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1107
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...

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.