0

当我调用 JSONAPI 库 ( http://mcjsonapi.com/ )的函数“callmultiple”时,会抛出一个 UriFormatExeption。但是,当我调用“调用”函数时,一切正常。下面我给你产生错误的代码:

JSONAPI j = new JSONAPI("minecraft20.omgserv.com", 40174, "username","password", "salt");
Dictionary<Object,Object> result = j.call("getServer",null); //all works
Dictionary<Object,Object) result2 = j.callMultiple(new string[] {"getServer", "getOfflinePlayers"},null) //UriFormatException is thrown

堆栈跟踪:

 System.UriFormatException n'a pas été gérée
    HResult=-2146233033
    Message=invalid uri : the authority/host could not be parse
    Source=System
    Stacktrace:
        at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
        at System.Uri..ctor(String uriString)
        at com.ramblingwood.minecraft.jsonapi.JSONAPI.makeURLMultiple(IEnumerable methods, IEnumerable args)
        at com.ramblingwood.minecraft.jsonapi.JSONAPI.callMultiple(IEnumerable methods, IEnumerable args)
        at MineControl.Server.Server.UpdateServer() dans c:\Users\frank\Documents\GitHub\MineControl\MineControl\Server\Server.cs:ligne 102
        at MineControl.Server.Server..ctor(String host, Int32 port, String id, String password, String salt) dans c:\Users\frank\Documents\GitHub\MineControl\MineControl\Server\Server.cs:ligne 56
        at MineControl.App..ctor() dans c:\Users\frank\Documents\GitHub\MineControl\MineControl\App.xaml.cs:ligne 26
        at MineControl.App.Main() dans c:\Users\frank\Documents\GitHub\MineControl\MineControl\obj\Debug\App.g.cs:ligne 0
        at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
        at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        at System.Threading.ThreadHelper.ThreadStart()
    InnerException:

我不明白为什么这段代码不好,所以请帮助我。感谢您

4

1 回答 1

1

我不知道这是否是问题所在,但文档说如果数组的长度和数组的长度不同,callMultiple则会引发异常。methodsargs

你有:

Dictionary<Object,Object) result2 = 
    j.callMultiple(new string[] {"getServer", "getOfflinePlayers"}, null);

您很可能需要编写:

Dictionary<Object,Object) result2 = 
    j.callMultiple(new string[] {"getServer", "getOfflinePlayers"}, 
                   new string[] {null, null});

无论如何,这就是我要尝试的。

于 2013-08-06T20:18:04.253 回答