小编Col*_*e F的帖子

为什么ResourceManager.GetResourceSet在构建后的第一个请求上返回null?(C#)

我正在研究一个用C#(asp.net)构建的大型Web应用程序.我有一个简单的aspx页面,它为客户端浏览器提供本地化字符串,以便在javascript控件中使用.为了获得字符串,我执行以下操作:

ResourceManager _resources = new ResourceManager(_pathname, typeof(ARM).Assembly);
ResourceSet rs = _resources.GetResourceSet(culture, false, false);

//loop through rs and write the keys & values out to the client in plaintext
Run Code Online (Sandbox Code Playgroud)

这一切都正常,除了在Clean/Build或Rebuild之后立即对页面的第一个请求(如果我只是进行一些更改,然后Build,它工作正常).所以在第一个请求时,当我尝试迭代ResourceSet时,我得到一个空引用异常.但是,如果我在错误之后刷新页面,那么从那时起它就能正常工作.

有谁知道为什么会发生这种情况?

c# asp.net resourcemanager nullreferenceexception

16
推荐指数
1
解决办法
8196
查看次数