我开始使用可选参数(因为我来自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
导致此问题的代码如下:
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
);
在哪里&#34;回应&#34;是Dictionary<string, object>
Dictionary<string, object> response = FacebookHelper.Deserialize(jsonString);
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;
}
}
有人能指出我解决这个问题的正确方向吗?
答案 0 :(得分:1)
这是一个真正的编译器错误,已经存在了很长时间。 Unity使用了一个旧的和错误的Mono版本的分支。它发生是因为命名参数。就个人而言,我有时可以使用命名参数,但在某些情况下,它只是在完全正确的代码上崩溃。不幸的是,我能给你的唯一建议是不要在Unity Mono编译器中使用命名参数。