1.在工程文件中加上以下配置:
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<PublishAot>true</PublishAot>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>
</PropertyGroup>
配置了PublishAot后,设计器会报错打不开,配置在发布时使用AOT即可(如下):
Condition="'$(Configuration)' == 'Release'"
2.有时在有些电脑上运行会报错:
System.NotSupportedException: COM Interop requires ComWrapper instance registered for marshalling.
at System.Runtime.InteropServices.ComWrappers.ComInterfaceForObject(Object) + 0x73
at System.Runtime.InteropServices.ComWrappers.ComInterfaceForObject(Object, Guid) + 0x20
at Interop.UiaCore.UiaReturnRawElementProvider(HWND, IntPtr, IntPtr, Interop.UiaCore.IRawElementProviderSimple) + 0x7c
at Interop.UiaCore.UiaReturnRawElementProvider(IHandle`1, WPARAM, LPARAM, Interop.UiaCore.IRa