[英]System.InvalidOperationException, Object in use elsewhere
[英]how to properly use: System.InvalidOperationException
这是Unity C#
//...
public static void Interupt(int Index, string Text){
try{
Change(Transforms[ Index ], Text);
}
catch{
throw new System.InvalidOperationException("Index: " + Index + " Is too large should be less than: " + Transforms.Count); // points me here
}
}
}
好的,这段代码将我指向
throw, ...
如何使我指向调用该函数的行?
喜欢:
using UnityEngine;
using System.Collections;
public class TestScript : MonoBehaviour {
void Start(){
SomeClass.Interupt(5, ""); // I want it to point me here
}
}
我确实尝试过这样做:
return throw new System.InvalidOperationException("Index: " + Index + " Is too large should be less than: " + Transforms.Count);
但我得到:
error CS1525: Unexpected symbol `throw'
女巫是完全合乎逻辑的。
但是我不知道的是Unity如何处理将我们指向函数而不是抛出线的事情?
希望大家对Unity Engine有所了解
如果只希望调试器跳转到调用Interrupt
的函数,而不是直接跳转到Interrupt,则可以使用DebuggerStepThroughAttribute
装饰Interrupt方法,即
[DebuggerStepThrough]
public static void Interupt(int Index, string Text)
{
try
{
Change(Transforms[Index], Text);
}
catch
{
throw new System.InvalidOperationException("Index: " + Index + " Is too large should be less than: " + Transforms.Count); // points me here
}
}
如果要以编程方式进行分析,则必须使用调用堆栈跟踪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.