在以下代码中,如果注释掉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");
......
}
1
idealhs 176 天前
你这是 Unity 吧?先说清楚环境,.NET 还是 mono 啥的
|
5
Eiden 176 天前
vs 可以远程调试的
|
7
idealhs 176 天前
@BBrother #4 没法开发机调的话,上 Visual Studio remote debugger
https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging?view=vs-2022 |