-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for InProc Com invocation #2035
Conversation
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc Globals hackathon mytool Packagedx parametermap whatifTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:yao-msft/winget-cli.git repository
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to have the sample caller app be able to swap to this as well for test purposes.
@@ -191,7 +191,7 @@ | |||
<Link> | |||
<SubSystem>Console</SubSystem> | |||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | |||
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies)</AdditionalDependencies> | |||
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">%(AdditionalDependencies)</AdditionalDependencies> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this now a no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I leave the node here in unlikely case we'll need something in the future.
|
||
extern "C" | ||
{ | ||
BOOL WINDOWS_PACKAGE_MANAGER_API_CALLING_CONVENTION DllMain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be using a macro for calling convention that is more in line with what this expects, not just whatever we happen to use.
|
||
WINDOWS_PACKAGE_MANAGER_API DllCanUnloadNow() | ||
{ | ||
return WindowsPackageManagerInProcModuleTerminate() ? S_OK : S_FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right way to do it? It seems like there are potential error paths here, although given the calling patterns it might be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this pattern is what I found in most other com dlls we wrote in the past.
|
||
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleInitialize() try | ||
{ | ||
::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::Create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need an initialization of our code? I suppose that might be what the state separation config would do.
We don't need to RegisterObjects
? Is that out-of-proc only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. RegisterObjects is for out of proc only. In proc automatically recognizes the creator map.
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc Globals hackathon mytool Packagedx parametermap whatifTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:yao-msft/winget-cli.git repository
|
Hey, @yao-msft @denelon @Trenly I have been trying to use In-Proc Winget COM APIs directly onto my c# app (.net 8) using CsWinRT to eventually install/search applications but the initial PackageManger object creation itself fails with below message System.TypeInitializationException: 'The type initializer for 'WinRT.ActivationFactory`1' threw an exception.' Can someone point me the right direction on how to achieve this maybe a straightforward example code snippet or documentation. Analysing the powershell (as it uses In-Proc) was getting a bit complicated and did not see any registrations before hand in the code instead the class objects (PackageManager etc) were directly being created in the P.S : The reason for going with this approach was because we wanted to execute the commands in the SYSTEM context and using direct powershell modules was not approved. |
Change
Added a shim dll to support in-proc Com activation of winget Com apis.
Validation
Validated by writing a sample caller consuming winget Com apis through in-proc activation. Codes run fine with in-proc activation.
Next
Microsoft Reviewers: Open in CodeFlow