You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to migrate wcR2 to .Net 6, but meet some blocking issue.
Here's the migration steps that I plan to take:
migrate .csproj to sdk-style project file, so that we can enjoy the latest C# lang feature.
add multi-target net462;net6.0-windows;netstandard2.0 and make it work. <- I'm blocking here.
upgrade dependency package version.
code style and performance optimization.
You know that wcR2 has strong dependence on Dotnetbar2. So far I can successfully build wcR2 when targeting net6.0, but can't open smoothly.
Here's the first error:
System.EntryPointNotFoundException: Unable to find an entry point named 'SetWindowTheme' in DLL 'user32'.
at DevComponents.DotNetBar.Controls.ComboBoxEx.SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList)
at DevComponents.DotNetBar.Controls.ComboBoxEx.ᛤ(IntPtr ह)
at DevComponents.DotNetBar.Controls.ComboBoxEx.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at DevComponents.DotNetBar.Controls.ComboBoxEx.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
It is really funny, by searching from msdn, we know that the SetWindowTheme function is declared in UxTheme.dll, not in user32. Also checked the disassemble code:
public class ComboBoxEx : ComboBox, ICommandSource
{
...
[DllImport("user32", CharSet = CharSet.Unicode)]
private static extern int SetWindowTheme(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string pszSubAppName, [MarshalAs(UnmanagedType.LPWStr)] string pszSubIdList);
private void ᛤ(IntPtr ह)
{
bool flag = false;
if (Environment.Version.Major > 5)
{
flag = true;
}
else if (Environment.Version.Major == 5 && Environment.Version.Minor >= 1)
{
flag = true;
}
if (flag)
{
SetWindowTheme(ह, " ", " ");
}
}
...
}
It checks the .net runtime version, if Environment.Version is equal to or greater than 5.1, then call SetWindowTheme on itself to reset themes.
This is also very confusing, I believe it should check Environment.OSVersion, because in .net Framework the version can't be greater than 5, so the function is never been called, and even no one was triggered the bug in the past 10 years.🤣
Finally I use Harmony to hook the function and replace with an empty function, now we can start wcR2-net6 version smoothly, only find the UI layout is a bit incorrect.
The second exception happens after loading base.wz and click any of the node:
System.TypeLoadException: Could not load type 'System.Windows.Forms.ContextMenu' from assembly 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at DevComponents.AdvTree.AdvTree.ټ(Node ٓ, MouseEventArgs ؿ, Point ٪)
at DevComponents.AdvTree.AdvTree.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
at Interop.User32.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WzComparerR2.Program.StartMainForm() in F:\Coding\visual studio 2012\Working Projects\WzComparerR2\WzComparerR2\Program.cs:line 44
at WzComparerR2.Program.Main() in F:\Coding\visual studio 2012\Working Projects\WzComparerR2\WzComparerR2\Program.cs:line 25
Dotnetbar2 is .Net FX 2.0 compatible, so it still checks System.Windows.Forms.ContextMenu type in its inner logic, but the class has already deprecated and removed from netcore codebase. see dotnet/winforms#2157
The class is not widely used, but the referenced function is very very long, I've no confidence that the decompiled code could work well. Also ContextMenu is used as property in some type, I can't remove them at runtime.
Now I'm stopping here and posting this thread. 😿
The text was updated successfully, but these errors were encountered:
Dotnetbar does not fully support .net core, I inject some function before starting, this may cause program unstable.
Default font changed, and may cause some UI layout to be incorrect. <- won't fix, we're planing to remake entire UI window with new framework.
Threading related functions are all deprecated, so long running jobs like Patcher and Comparer can't interrupt, will refactor to Task based functions to support these operation.
ListViewItems are all highlighted even they're not selected, this is just a visual issue, never mind.
TBD
Kagamia
changed the title
.Net6 migration blocking
Announcement: WcR2 .Net6 alpha version is ready.
Oct 9, 2023
I'm trying to migrate wcR2 to .Net 6, but meet some blocking issue.
Here's the migration steps that I plan to take:
.csproj
to sdk-style project file, so that we can enjoy the latest C# lang feature.net462;net6.0-windows;netstandard2.0
and make it work. <- I'm blocking here.You know that wcR2 has strong dependence on
Dotnetbar2
. So far I can successfully build wcR2 when targeting net6.0, but can't open smoothly.Here's the first error:
It is really funny, by searching from msdn, we know that the
SetWindowTheme
function is declared inUxTheme.dll
, not inuser32
. Also checked the disassemble code:It checks the .net runtime version, if
Environment.Version
is equal to or greater than 5.1, then callSetWindowTheme
on itself to reset themes.This is also very confusing, I believe it should check
Environment.OSVersion
, because in .net Framework the version can't be greater than 5, so the function is never been called, and even no one was triggered the bug in the past 10 years.🤣Finally I use
Harmony
to hook the function and replace with an empty function, now we can start wcR2-net6 version smoothly, only find the UI layout is a bit incorrect.The second exception happens after loading base.wz and click any of the node:
Dotnetbar2
is .Net FX 2.0 compatible, so it still checksSystem.Windows.Forms.ContextMenu
type in its inner logic, but the class has already deprecated and removed from netcore codebase. see dotnet/winforms#2157The class is not widely used, but the referenced function is very very long, I've no confidence that the decompiled code could work well. Also
ContextMenu
is used as property in some type, I can't remove them at runtime.Now I'm stopping here and posting this thread. 😿
The text was updated successfully, but these errors were encountered: