【MS CLR】咨询进度条混合编程接口问题?

CLR编写

C#调用

结果崩了,这个不晓得怎么测试,单从代码层面能看出错误不呢?

Parents
  • P/Invoke调用就好了,没必要用clr方式,这种封装好的函数又不需要调试的。

      public static class Class1
        {
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static IntPtr mdlDialog_completionBarOpen(string messageText);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarUpdate(IntPtr dialog, string messageText, int percent);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarDisplayMessage(IntPtr dialog, string messageText);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarClose(IntPtr dialog);
    
            public static void Test(string unparsed)
            {
                var ptr = mdlDialog_completionBarOpen("测试");
                System.Threading.Thread.Sleep(1000);
    	//下面这一行,测试了下,感觉用不上
                //mdlDialog_completionBarDisplayMessage(ptr, "测试2");
                for (int i = 0; i <= 10; i++)
                {
                    mdlDialog_completionBarUpdate(ptr, $"更新{i}", i * 10);
                    System.Threading.Thread.Sleep(200);
    
                }
                System.Threading.Thread.Sleep(1000);
                mdlDialog_completionBarClose(ptr);
                return;
            }
    }

    MISSING RESOURCE: VerifiedBy aoteman 

Reply
  • P/Invoke调用就好了,没必要用clr方式,这种封装好的函数又不需要调试的。

      public static class Class1
        {
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static IntPtr mdlDialog_completionBarOpen(string messageText);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarUpdate(IntPtr dialog, string messageText, int percent);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarDisplayMessage(IntPtr dialog, string messageText);
            [DllImport("ustation.dll", CharSet = CharSet.Unicode)]
            public extern static void mdlDialog_completionBarClose(IntPtr dialog);
    
            public static void Test(string unparsed)
            {
                var ptr = mdlDialog_completionBarOpen("测试");
                System.Threading.Thread.Sleep(1000);
    	//下面这一行,测试了下,感觉用不上
                //mdlDialog_completionBarDisplayMessage(ptr, "测试2");
                for (int i = 0; i <= 10; i++)
                {
                    mdlDialog_completionBarUpdate(ptr, $"更新{i}", i * 10);
                    System.Threading.Thread.Sleep(200);
    
                }
                System.Threading.Thread.Sleep(1000);
                mdlDialog_completionBarClose(ptr);
                return;
            }
    }

    MISSING RESOURCE: VerifiedBy aoteman 

Children
No Data