Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 291561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:06:01+00:00 2026-05-12T06:06:01+00:00

I implemented a python com server and generate an executable and dll using py2exe

  • 0

I implemented a python com server and generate an executable and dll using py2exe tool.
then I used regsvr32.exe to register the dll.I got a message that the registration was successful. Then I tried to add reference to that dll in .NET. I browsed to the dll location and select it, but I got an error message box that says: A reference to the dll could not be added, please make sure that the file is accessible and that it is a valid assembly or COM component.The code of the server and setup script is added below.
I want to mention that I can run the server as a python script and consume it from .net using late binding.
Is there something I’m missing or doing wrong? I would appreciate any help.

thanks,
Sarah

hello.py

import pythoncom

import sys

class HelloWorld:

    #pythoncom.frozen = 1
    if hasattr(sys, 'importers'):
        _reg_class_spec_ = "__main__.HelloWorld" 
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
    _reg_clsid_ = pythoncom.CreateGuid()
    _reg_desc_ = "Python Test COM Server"
    _reg_progid_ = "Python.TestServer"
    _public_methods_ = ['Hello']
    _public_attrs_ = ['softspace', 'noCalls']
    _readonly_attrs_ = ['noCalls']
    
    def __init__(self):
        self.softspace = 1
        self.noCalls = 0

    def Hello(self, who):
        self.noCalls = self.noCalls + 1
        # insert "softspace" number of spaces
        print "Hello" + " " * self.softspace + str(who)
        return "Hello" + " " * self.softspace + str(who)


if __name__=='__main__':
    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.UseCommandLine(HelloWorld)
        else:

            # start the server.
            from win32com.server import localserver
            localserver.main()
    else:

        import win32com.server.register
        win32com.server.register.UseCommandLine(HelloWorld) 

setup.py

from distutils.core import setup
import py2exe

setup(com_server = ["hello"])
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:06:01+00:00Added an answer on May 12, 2026 at 6:06 am

    I will answer my question to help any one may have similar questions. I hope that would help.
    I can not find my server on the COM tab because, .NET (& Visual-Studio) need COM servers with TLB. But Python’s COM servers have no TLB.
    So to use the server from .NET by (C# and Late binding). The following code shows how to make this:

    // the C# code

    using System;
    
    using System.Collections.Generic;
    
    using System.Linq;
    
    using System.Text;
    
    using System.Reflection;
    
    namespace ConsoleApplication2
    
    {
    
        class Program
    
        {
            static void Main(string[] args)
    
            {
    
                  Type pythonServer;
                  object pythonObject;
                  pythonServer = Type.GetTypeFromProgID("PythonDemos.Utilities");
                  pythonObject = Activator.CreateInstance(pythonServer);
    
            }
        }
    }   `
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 197k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer best to use: <link href="<%=ResolveUrl("~/css/style.css") %>" rel="stylesheet" type="text/css /> since… May 12, 2026 at 7:19 pm
  • Editorial Team
    Editorial Team added an answer need to creat key first and put them on the… May 12, 2026 at 7:19 pm
  • Editorial Team
    Editorial Team added an answer A good way to do this for performance reasons is… May 12, 2026 at 7:19 pm

Related Questions

What would be the best way to implement a simple crash / error reporting
I'm attempting to implement a simple Single Sign On scenario where some of the
I am looking for a python webserver which is multithreaded instead of being multi-process
I am using python for making a COM local server. In fact, the whole

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.