System.ArgumentNullException在ResourceManager.GetString内部 [英] System.ArgumentNullException in ResourceManager.GetString internals

查看:142
本文介绍了System.ArgumentNullException在ResourceManager.GetString内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code:

System.Resources.ResourceManager resourceManager = GetResourceManager();
string str = resourceManager.GetString("delete", new CultureInfo(1033));

在当前项目中的.NET下编译2.0一切正常除外。可变的 STR 的包含LCID 1033资源字符串 - 删除,这是确定

In current project compiled under .NET 2.0 everything works as excepted. Variable str contains resource string for LCID 1033 - Delete, this is ok.

我们现在正在升级到.NET 4.0,目标框架.NET 4.0下重新编译项目。 现在,编译成.NET 4.0组件,它会抛出异常的 System.ArgumentNullException 与消息的值不能为null .STACK跟踪:

We are now upgrading to .NET 4.0, recompiled project under target framework .NET 4.0. Now compiled as .NET 4.0 assemblies, it throws exception System.ArgumentNullException with message Value cannot be null..Stack trace:

   at System.Threading.Monitor.Enter(Object obj)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)

有趣这里是堆栈跟踪,它指向的内部框架方法 ResourceManager.InternalGetResourceSet ,导致叫 Monitor.Enter 与空对象。但我的方法调用的的GetString 的与非空参数的的GetString(删除,新的CultureInfo(1033))的。

Interesting here is stacktrace, where it points to internal framework method in ResourceManager.InternalGetResourceSet which causes to call Monitor.Enter with null object. But i call method GetString with not null parameters GetString("delete", new CultureInfo(1033)).

这个错误似乎是类似于<一href="http://stackoverflow.com/questions/1655182/system-argumentnullexception-in-system-threading-monitor-enter">System.ArgumentNullException在System.Threading.Monitor.Enter 的。在Monitor.Enter也许一些bug,还是其他什么东西?

This bug seems to be similar to System.ArgumentNullException in System.Threading.Monitor.Enter. Maybe some bug in Monitor.Enter, or something else?

更新: 当我看到在调试器对象 resourceManager.ResourceSets.Items [2] .Value.Table [删除] 则包含字符串值删除。物业项目[2]这里指着LCID 1033这意味着,资源管理器已经包含在语言资源键的删除的本地化字符串的 1033 的。有谁知道在哪里可以是错误?

Update: When i look in debugger at object resourceManager.ResourceSets.Items[2].Value.Table["delete"] then it contains string value "Delete". property Items[2] here pointing to LCID 1033. This means that resource manager already contains localized string for resource key delete in language 1033. Does anybody knows where can be error?

推荐答案

我也认为你应该声明和使用自己的字典进行存储,因为ResourceSets标记.NET 4.0下的过时

I also think that you should declare and use your own dictionary for storage since ResourceSets is marked as Obsolete under .NET 4.0

这篇关于System.ArgumentNullException在ResourceManager.GetString内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆