[python-win32] Problem registering COM server at installation time

eryk sun eryksun at gmail.com
Mon Feb 1 04:26:01 EST 2016


On Sun, Jan 31, 2016 at 10:42 PM, Mark Hammond <skippy.hammond at gmail.com> wrote:
> On 17/01/2016 6:51 AM, Malte Forkel wrote:
>>
>> I'm trying the register a COM server using the install script of a built
>> distribution, created with the  bdist_wininst format of distutils. But
>> the script fails with a message that MSVCR90.dll can't be found.
>> Registering the server after the installer is done works fine. I'm using
>> Python 2.7.11 and pywin32-220 on Windows 7.1 64 bit.
>
> That sounds a little strange - the script should only be executed after
> python27.dll is loaded, which itself relies on msvcr90.dll.
>
> Does it happen to work if you put the installer executable in the same
> directory as python27.dll?

Loading msvcr90.dll requires a SxS activation context. Neither
pythoncom27.dll nor pywintypes27.dll have this assembly embedded as
resource #2. I assume that's because they're normally loaded as
extension modules. In this case Python uses the activation context
that gets saved in its DllMain, which includes the VC90 assembly from
the #2 manifest that's embedded in python27.dll. Are these two DLLs
getting loaded in some other way here? If so you can create a context
at runtime from the manifest that's embedded in python27.dll.

pythoncomloader27.dll can load msvcr90.dll because it has the
following manifest embedded as resource #2:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker"
uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT"
version="9.0.21022.8" processorArchitecture="amd64" publi
cKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>


More information about the python-win32 mailing list