Skip to content
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

Why some conputer run AOT exe show error dialog,but others not? #61

Open
newcoder7777 opened this issue May 26, 2023 · 8 comments
Open

Comments

@newcoder7777
Copy link

newcoder7777 commented May 26, 2023

my computer show error dialog like this,but my another computer not

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NotSupportedException: COM Interop requires ComWrapper instance registered for marshalling.
at System.Runtime.InteropServices.ComWrappers.ComObjectForInterface(IntPtr) + 0x59
at System.Windows.Forms.UnsafeNativeMethods.CreateStdAccessibleObject(HandleRef, Int32, Guid&, Object&) + 0xbb
at System.Windows.Forms.AccessibleObject.UseStdAccessibleObjects(IntPtr, Int32) + 0x4a
at System.Windows.Forms.ButtonBase.ButtonBaseAccessibleObject..ctor(Control) + 0x35
at System.Windows.Forms.Button.CreateAccessibilityInstance() + 0x23
at System.Windows.Forms.Control.get_AccessibilityObject() + 0x60
at System.Windows.Forms.Control.GetAccessibilityObject(Int32 accObjId) + 0x14
at System.Windows.Forms.Control.WmGetObject(Message& m) + 0x84
at System.Windows.Forms.Control.WndProc(Message& m) + 0x141
at System.Windows.Forms.ButtonBase.WndProc(Message& m) + 0x17d
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Interop.User32.WM msg, IntPtr wparam, IntPtr lparam) + 0x70

@kant2002
Copy link
Owner

I belive you miss call to ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance); which make WinForms works. Like it done here.

ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance);

@kant2002
Copy link
Owner

Other option is that you have some IME tools or other apps which provide accessibility service. Any ideas what can it be?

@newcoder7777
Copy link
Author

Thanks for your replay, I know need add ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance);

But I want to know, why not add this code, after publish, some conputer run AOT exe show error dialog,but others not

Another question : I add richTextBox to my Form, then Vistual Studio show error dialog : Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information. Although, I still can publish my program

@newcoder7777
Copy link
Author

Another Question: I found you publish WinFormsComInterop.SourceGenerator in NUGET
But no readme for WinFormsComInterop.SourceGenerator to let us know what is it and How to use it.
Sorry, my language is not English , I used translate software

@newcoder7777
Copy link
Author

Another Question: Is it AOT not support System.Management ?

If I not open AOT, that code return true. But when I use AOP , and add myClss in rd.xml, still return false

public static bool IsWmiServiceOpen()
{
try
{
ServiceController controller = new ServiceController("winmgmt");
if (controller.Status != ServiceControllerStatus.Running)
return false;
}
catch
{
return false;
}

        try
        {
            ManagementClass mc = new ManagementClass("Win32_Service");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if (mo["Name"].ToString().ToLower() == "winmgmt")
                    return (mo["Started"].ToString().ToLower() == "true");
            }
            return false;
        }
        catch
        {
            return false;
        }
    }

@kant2002
Copy link
Owner

There no support for System.Management and currently it is very complicated to implement. I did take a look at it, but give up. WMI uses a lot of abstractions, so I cannot create fixed proxy. Unfortunately.

@newcoder7777
Copy link
Author

System.Management

Thank you very much . One Question, Is rd.xml could be generate automatic ? I don't know the WinFormsComInterop.SourceGenerator is do for that ?

@NCLnclNCL
Copy link

Another Question: Is it AOT not support System.Management ?

If I not open AOT, that code return true. But when I use AOP , and add myClss in rd.xml, still return false

public static bool IsWmiServiceOpen() { try { ServiceController controller = new ServiceController("winmgmt"); if (controller.Status != ServiceControllerStatus.Running) return false; } catch { return false; }

        try
        {
            ManagementClass mc = new ManagementClass("Win32_Service");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if (mo["Name"].ToString().ToLower() == "winmgmt")
                    return (mo["Started"].ToString().ToLower() == "true");
            }
            return false;
        }
        catch
        {
            return false;
        }
    }

i think you can using command line to get it

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

No branches or pull requests

3 participants