跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 分享一个 C#程序的神秘 bug,顺便问问为什么会这样?

发表于

在以下代码中,如果注释掉UIDocument UIDocument = new UIDocument(Document);这一行代码(倒数第二行),运行后可以正常输出到init finish,但是这行代码如果存在则只能输出到$"2, {clientId.GetGUID()}"这一行,然后会报运行时错误:

未经处理的异常:  System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

为什么会存在这种后面还没运行到的代码可以影响前面代码的报错?

 [STAThread]
        static void Main(string[] args)
        {
            // 初始化
            Init();
            Product revitInstance = Product.GetInstalledProduct();
            Console.WriteLine("1");
            var clientId = new ClientApplicationId(Guid.NewGuid(), "testing", "ADSK.Username");
            Console.WriteLine($"2, {clientId.GetGUID()}");
            revitInstance.Init(clientId, "I am authorized by Autodesk to use this UI-less functionality.");
            Console.WriteLine("3");
            Autodesk.Revit.ApplicationServices.Application Application = revitInstance.Application;
            Console.WriteLine("4");
            Document Document = Application.OpenDocumentFile(inputPath);
            Console.WriteLine("5");
            UIDocument UIDocument = new UIDocument(Document);
            Console.WriteLine("init finish");
            
            ......
        }

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.