当传递一个静态字符串到这个委托时,我得到了这个问题,我试着将静态字符串的值复制到普通字符串,它工作正常。NullReferenceException外部代码Xamarin-Android
((JsonHttpClient)connection).RequestFilter = httpReq =>
{
string authtoken = MemoryCache.authToken;
httpReq.Headers.Add(UdareConstants.AuthTokenKey, authtoken);
};
此外,硬编码值的工作正常。
((JsonHttpClient)connection).RequestFilter = httpReq =>
{
string authtoken = "62bebc52-fde3-4f47-beab-6a3e4e3440f0";
httpReq.Headers.Add(UdareConstants.AuthTokenKey, authtoken);
};
MemoryCache
这是一个静态类和authToken
财产这是一个静态的字符串。
这让我疯狂。
你是如何初始化MemoryCache.authToken的? –
开始的代码我做 MemoryCache.authToken =“62bebc52-fde3-4f47-beab-6a3e4e3440f0”; – Loucry
您可以尝试添加数据断点来调查该错误。这可能是有趣的:http://stackoverflow.com/questions/4086039/data-breakpoints-in-java-eclipse –