kant2002 / WinFormsComInterop

ComWrappers required to run NativeAOT and WinForms
MIT License
215 stars 31 forks source link

WPF support #30

Open kant2002 opened 2 years ago

kant2002 commented 2 years ago

So far with .NET 7 I can list following issues

  1. Output form ILC. CoClass usage should be replaced with ComWrappers

    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass.CreateSpellChecker(string), because: Invalid IL or CLR metadata in 'ISpellChecker SpellCheckerFactoryCoClass.CreateSpellChecker(System.String)'
    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass.IsSupported(string), because: Invalid IL or CLR metadata in 'Int32 SpellCheckerFactoryCoClass.IsSupported(System.String)'
    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass.RegisterUserDictionary(string,string), because: Invalid IL or CLR metadata in 'Void SpellCheckerFactoryCoClass.RegisterUserDictionary(System.String, System.String)'
    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass.UnregisterUserDictionary(string,string), because: Invalid IL or CLR metadata in 'Void SpellCheckerFactoryCoClass.UnregisterUserDictionary(System.String, System.String)'
    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass.get_SupportedLanguages(), because: Invalid IL or CLR metadata in 'IEnumString SpellCheckerFactoryCoClass.get_SupportedLanguages()'
    ILC: Ignoring unresolved method [PresentationFramework]System.Windows.Documents.MsSpellCheckLib.RCW+SpellCheckerFactoryCoClass..ctor(), because: Invalid IL or CLR metadata in 'Void SpellCheckerFactoryCoClass..ctor()'
    ILC: Ignoring unresolved method [PresentationCore]MS.Internal.AppModel.CustomCredentialPolicy+InternetSecurityManager..ctor(), because: Invalid IL or CLR metadata in 'Void InternetSecurityManager..ctor()'
    ILC: Ignoring unresolved method [System.DirectoryServices]System.DirectoryServices.Interop.UnsafeNativeMethods+PropertyValue..ctor(), because: Invalid IL or CLR metadata in 'Void PropertyValue..ctor()'
    ILC: Ignoring unresolved method [System.DirectoryServices]System.DirectoryServices.Interop.UnsafeNativeMethods+PropertyEntry..ctor(), because: Invalid IL or CLR metadata in 'Void PropertyEntry..ctor()'
    ILC: Ignoring unresolved method [ReachFramework]System.Windows.Xps.Serialization.RCW.XpsOMThumbnailGeneratorClass.GenerateThumbnail(IXpsOMPage,XPS_IMAGE_TYPE,XPS_THUMBNAIL_SIZE,IOpcPartUri), because: Invalid IL or CLR metadata in 'System.Windows.Xps.Serialization.RCW.IXpsOMImageResource System.Windows.Xps.Serialization.RCW.XpsOMThumbnailGeneratorClass.GenerateThumbnail(System.Windows.Xps.Serialization.RCW.IXpsOMPage, System.Windows.Xps.Serialization.RCW.XPS_IMAGE_TYPE, System.Windows.Xps.Serialization.RCW.XPS_THUMBNAIL_SIZE, System.Windows.Xps.Serialization.RCW.IOpcPartUri)'
    ILC: Ignoring unresolved method [ReachFramework]System.Windows.Xps.Serialization.RCW.XpsOMThumbnailGeneratorClass..ctor(), because: Invalid IL or CLR metadata in 'Void System.Windows.Xps.Serialization.RCW.XpsOMThumbnailGeneratorClass..ctor()'
    ILC: Ignoring unresolved method [WindowsBase]MS.Internal.Security.AttachmentService+AttachmentServices..ctor(), because: Invalid IL or CLR metadata in 'Void AttachmentServices..ctor()'
    ILC: Ignoring unresolved method [DirectWriteForwarder]<Module>.qsort(void*,uint32,uint32,(*int32)(void*,void*)), because: Vararg call to 'Int32 <Module>._CrtDbgReportW(Int32, Char*, Int32, Char*, Char*)' not supported
    ILC: Ignoring unresolved method [DirectWriteForwarder]<Module>.qsort_s(void*,uint32,uint32,(*int32)(void*,void*,void*),void*), because: Vararg call to 'Int32 <Module>._CrtDbgReportW(Int32, Char*, Int32, Char*, Char*)' not supported
    ILC: Ignoring unresolved method [DirectWriteForwarder]<Module>.bsearch(void*,void*,uint32,uint32,(*int32)(void*,void*)), because: Vararg call to 'Int32 <Module>._CrtDbgReportW(Int32, Char*, Int32, Char*, Char*)' not supported
    ILC: Ignoring unresolved method [DirectWriteForwarder]<Module>.bsearch_s(void*,void*,uint32,uint32,(*int32)(void*,void*,void*),void*), because: Vararg call to 'Int32 <Module>._CrtDbgReportW(Int32, Char*, Int32, Char*, Char*)' not supported
    ILC: Ignoring unresolved method [DirectWriteForwarder]<Module>.std._Iterator_base12._Orphan_me_unlocked_v3(_Iterator_base12*), because: Vararg call to 'Int32 <Module>._CrtDbgReport(Int32, SByte*, Int32, SByte*, SByte*)' not supported
    ILC: Ignoring unresolved method [WinFormsComInterop]WinFormsComInterop.WinFormsComWrappers.ComputeVtables(object,CreateComInterfaceFlags,int32&), because: Failed to load type 'System.Windows.Forms.InternalAccessibleObject' from assembly 'System.Windows.Forms, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    ILC: Ignoring unresolved method [System.Printing]<Module>.std._Iterator_base12._Orphan_me_unlocked_v3(_Iterator_base12*), because: Vararg call to 'Int32 <Module>._CrtDbgReport(Int32, SByte*, Int32, SByte*, SByte*)' not supported
    ILC: Ignoring unresolved method [PresentationFramework]MS.Internal.AppModel.AppSecurityManager+InternetSecurityManager..ctor(), because: Invalid IL or CLR metadata in 'Void InternetSecurityManager..ctor()'
  2. DirectWriteForwarder crash in main. That is blocker

0:000> kc
 # Call Site
00 WpfTestBed!HndWriteBarrierWorker
01 WpfTestBed!HndWriteBarrier
02 WpfTestBed!HndAssignHandle
03 WpfTestBed!GCHandleManager::StoreObjectInHandle
04 WpfTestBed!S_P_CoreLib_System_Runtime_InteropServices_GCHandle__set_Target
05 WpfTestBed!DirectWriteForwarder__Module___gcroot_System__String_____
06 WpfTestBed!DirectWriteForwarder__Module____CrtImplementationDetails__LanguageSupport_Initialize
07 WpfTestBed!DirectWriteForwarder__Module____cctor
08 WpfTestBed!S_P_CoreLib_Internal_Runtime_CompilerHelpers_StartupCodeHelpers__RunInitializers
09 WpfTestBed!S_P_CoreLib_Internal_Runtime_CompilerHelpers_StartupCodeHelpers__RunModuleInitializers
0a WpfTestBed!WpfTestBed__Module___StartupCodeMain
0b WpfTestBed!wmain
0c WpfTestBed!invoke_main
0d WpfTestBed!__scrt_common_main_seh
0e KERNEL32!BaseThreadInitThunk
0f ntdll!RtlUserThreadStart
unofficialdev commented 2 years ago

@kant2002 Does this mean there is progress in wpf support?

kant2002 commented 2 years ago

@unofficialdev I did not forget about WPF. I refresh what I have to run on WPF7 and discover that I have to rewrite at least DirectWriteForwarder. That was expected, but my hopes was, that I can at least somehow show empty form.

This requires me to go all-in. That's risky and nothing which I can do in small incremental steps.

I'm looking for options how I can pay risks in smaller pieces. If I would not find a way, I will try to go all-in and check what happens.

If you know community of developers who willing to at least test experiement, or company who willing to probe the water, I can take more risky stance on the matter.

unofficialdev commented 2 years ago

Does it really benefit WPF apps? Do people really need that? compiling with Native AOT can give WPF resistance to decompile IL code. a problem that a lot of developers want. unfortunately I can't afford to contribute :(

kant2002 commented 2 years ago

https://github.com/dotnet/wpf/issues/5305#issuecomment-1148621250

With custom WPF build I think people can start playing with NativeAOT and WPF

ccarlo88 commented 2 years ago

You did the impossible Mr. @kant2002 , thank you! 👏 🥳 Do you believe this will eventually go to the official channel release anytime in the future?

kant2002 commented 2 years ago

I would say, this questions better ask in WPF repo. First things is to make sure that WPF accepts community contribution on more faster cadence. If you want this, please go to WPF repo and express your request there. Team should know that people want WPF to be community driven,

AlexsandroZanella2 commented 1 year ago

wpf support for native AOT would be very useful for my company, I'm developing several tools in avalonia because wpf is not supported