Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

COM Support #8248

Open
VS-ux opened this issue Jul 26, 2020 · 6 comments
Open

COM Support #8248

VS-ux opened this issue Jul 26, 2020 · 6 comments

Comments

@VS-ux
Copy link

VS-ux commented Jul 26, 2020

HI!
So I've seen this repo for a couple of months and it's pretty cool. However, I was wondering when or how COM will be supported.
Keep in mind this type of stuff is not my area of expertise so I apologize for any mistakes.

I use Winforms alot and that includes using things such as OpenFileDialog. However, since COM isn't supported, these things don't work. Issue #4219 showed some examples and this sample helped alot. However, when CoreRT'ing and starting the binary it failed. I think it's because I didn't follow step 6 as listed here. I'm unsure what to do on that step. Can somebody guide me through what to do? (I really just need support for MenuStrip, ContextMenuStrip, ToolStrip, and possibly StatusStrip.
Thanks

@jkotas
Copy link
Member

jkotas commented Jul 26, 2020

#8143 has discussion about the implementation strategy for ComWrappers in CoreRT. These comments points to components that you may be able to reuse:

#8143 (comment)
#8143 (comment)

MenuStrip, ContextMenuStrip, ToolStrip, and possibly StatusStrip.

You can ignore the "tracker" part of the ComWrappers functionality like RegisterForTrackerSupport for these.

cc @kant2002 @AaronRobinsonMSFT @jkoritzinsky

@VS-ux
Copy link
Author

VS-ux commented Jul 28, 2020

Hi! I'm so sorry about the late reply.
I was wondering what I would do to implement COM. Do I merge #8143? If I merge it, is there any more work that needs to be done such as setting the ComWrappers object into the Winforms controls?
I really apologize if this is really stupid, I don't know much about this area.

@Joshquinberoani
Copy link

@jkotas I'm confused about this aswell. It would improve the value of CoreRT even more.

@AaronRobinsonMSFT
Copy link
Member

@Joshquinberoani and @VS-ux I will link to a reply I made in the C#/WinRT repo. I want to make sure expectations are understood about the API in question - it isn't technically needed for COM support and has nothing to do with the built-in COM support. See microsoft/CsWinRT#308 (comment).

@jkotas
Copy link
Member

jkotas commented Aug 3, 2020

The built-in COM support in classic .NET runtimes is not AOT friendly.

It is not possible to reliably compute the set of COM interop wrappers that the application is going to need. Well, one can say that it will need everything possible but then the resulting binary is going to be big that defeats the point of runtime optimized for AOT. You can just use CoreCLR as it exists today and it is likely going to work better.

Even if it was possible to reliably compute this set, it is not desirable to build the pre-generation of all COM interop marshaling into the AOT compiler since it is very complex. It is better to delegate both figuring out the set of COM interop wrappers that are required and their generation to an external tool.

ComWrappers helps in two ways:

  • It makes it possible to implement COM interop wrappers efficiently.
  • It makes it possible to inject COM interop wrappers into the system, so that existing components that use e.g. System.Runtime.InteropServices.Marshal APIs or use COM interfaces in P/Invoke signatures continue to work without changes.

@VS-ux
Copy link
Author

VS-ux commented Aug 3, 2020

@jkotas Hi!
So I downloaded #8143 and built CoreRT (I skipped the tests because they took too long). I then downloaded https://github.com/kant2002/CoreRTWinFormsTestBed/tree/master/WinFormsComInterop, and ran it as is. It worked. Then, I edited the csprojs to use the custom built #8143 CoreRt. I built the project using Cmd and Publish, however I got an error saying could not open "kernal32.lib". I fixed it by using x64 native command prompt. It then built OK. But then, when running the native binary, I got this error:

` ntdll.dll!00007ffab3935854() Unknown
KernelBase.dll!00007ffab1452f07() Unknown
WindowsFormsApp1.exe!S_P_CoreLib_Interop_mincore__RaiseFailFastException_0�() Unknown

WindowsFormsApp1.exe!S_P_CoreLib_Interop_mincore__RaiseFailFastException() Line 49 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_RuntimeExceptionHelpers__FailFast_1() Line 263 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_RuntimeExceptionHelpers__RuntimeFailFast() Line 216 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_Runtime_CalliIntrinsics__Call_5�() Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_Runtime_CalliIntrinsics__CallVoid_3() Line 17 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_Runtime_EH__UnhandledExceptionFailFastViaClasslib() Line 251 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_Runtime_EH__DispatchEx() Line 711 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_System_Runtime_EH__RhThrowEx() Line 617 Unknown
WindowsFormsApp1.exe!RhpThrowEx() Line 191 Unknown
WindowsFormsApp1.exe!S_P_CoreLib_Internal_Runtime_CompilerHelpers_ThrowHelpers__ThrowTypeLoadException() Line 64 Unknown
WindowsFormsApp1.exe!WindowsFormsApp1_WindowsFormsApp1_Program__Main�() Unknown
WindowsFormsApp1.exe!WindowsFormsApp1__Module___MainMethodWrapper() Unknown
WindowsFormsApp1.exe!WindowsFormsApp1__Module___StartupCodeMain() Unknown
WindowsFormsApp1.exe!wmain(int argc, wchar_t * * argv) Line 447 C++
[Inline Frame] WindowsFormsApp1.exe!invoke_main() Line 90 C++
WindowsFormsApp1.exe!__scrt_common_main_seh() Line 288 C++
kernel32.dll!00007ffab25730f4() Unknown
ntdll.dll!00007ffab38ca33b() Unknown`

Does anybody know a fix to this?
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants