[英]Optional Parameters causing a InternalErrorException
I'm starting to use Optional parameters (as I came from java and haven't ever experimented with them before) and I'm running into the following issue: 我开始使用可选参数(因为我来自java,以前从未尝试过使用它们),并且遇到了以下问题:
Unhandled Exception: Mono.CSharp.InternalErrorException: Internal error
at Mono.CSharp.MethodGroupExpr.IsApplicable (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& arguments, Int32 arg_count, System.Reflection.MethodBase& method, System.Boolean& params_expanded_form) [0x00000] in <filename unknown>:0
at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& Arguments, Boolean may_fail, Location loc) [0x00000] in <filename unknown>:0
at Mono.CSharp.New.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.Assign.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.SimpleAssign.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0
at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.If.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0
at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0
The code causing this issue is here: 导致此问题的代码在这里:
Me = new UserAccount(
name: response["first_name"] as string,
age: DateToAge(response["birthday"] as string),
facebookID: response["id"] as string,
email: response["email"] as string,
gender: (response["gender"] as string == "male") ? 0 : 1
);
Where "response" is a Dictionary<string, object>
其中“响应”是
Dictionary<string, object>
Dictionary<string, object> response = FacebookHelper.Deserialize(jsonString);
And the UserAccount class is here: 而UserAccount类在这里:
public class UserAccount {
public string SessionKey;
public string FacebookID;
public string Name;
public string Email;
public int Age;
public int Gender;
public GeoLocation Location;
public Texture Avatar;
public UserAccount(string name, int age, int gender, string email = "", GeoLocation location = null, string sessionKey = "", string facebookID = "", Texture avatar = null) {
Name = name;
Email = email;
Age = age;
Gender = gender;
Location = location;
SessionKey = sessionKey;
FacebookID = facebookID;
Avatar = avatar;
}
}
Could anyone point me in the correct direction of resolving this? 谁能指出我解决这个问题的正确方向?
This is a genuine compiler error that's been there for a long time. 这是一个长期存在的真正的编译器错误。 Unity uses a fork of an old and buggy version of Mono.
Unity使用的是旧版本的Mono的分支。 It happens because of named parameters.
它是由于命名参数而发生的。 Personally, I was able to use named parameters sometimes, but in some cases it just crashed on a completely correct code.
就个人而言,有时我可以使用命名参数,但是在某些情况下,它只是崩溃在完全正确的代码上。 Unfortunately, the only advice I can give you is not to use named parameters with Unity Mono compiler.
不幸的是,我只能为您提供的建议是不要在Unity Mono编译器中使用命名参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.