I am trying to use COM object in regitration-free fashion in powershell. My component is x86 and poweshell_ise.exe is x86 also.
To do this I have created manifest for dll-based com server:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="ComComponent" processorArchitecture="X86" type="win32" version="1.0.0.0"></assemblyIdentity>
<file name="ComComponent.dll" hashalg="SHA1">
<comClass clsid="{<CLASS_CLSID>}" tlbid="{<TLB_CLSID>}" progid="ComComponent.ComComponent" description="ComComponent Class"»
<typelib tlbid="{<TLB_CLSID>}" version="1.0" resourceid="2" helpdir="" flags="HASDISKIMAGE"></typelib>
</file>
</assembly>
And manifest for the powershell script:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="PSScript" type="win32" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="ComComponent" version="1.0.0.0"
processorArchitecture="x86" />
</dependentAssembly>
</dependency>
</assembly>
In powershell I am using it in the following way:
$actctx = New-Object -COM Microsoft.Windows.ActCTX
$actctx.Manifest = "<path to manifest>"
$obj= $actctx.CreateObject("ComComponent.ComComponent")
$obj.ComMethod()
After that I am getting the following error:
Method invocation failed because [System.__ComObject] does not contain a method named 'ComMethod'.
I can see that ComComponent.dll
is loaded into powershell_ise.exe
in Process Explorer. Also I can see that powershell for some reason is trying to read HKCR\TypeLib\{<TLB_CLSID>}
registry key.
The same functionality is working in powershell with registred COM. I have tried to put type library into separate file with the same result.
What can be the problem? Thank you