http://dev.csdn.net/article/76585.shtm这篇文章写的我都明白,但是如果我把资源文件放在自己开发组件中那又该怎么办??
也就是说自定义组件如何获取调用它的程序的CurrentCulture和CurrentUICulture区域性信息?
(自定义组件可能在exe/asp.net中使用)

解决方案 »

  1.   

    有一点我不明白... Thread ,Assembly, AppDomain之间是什么关系??
      

  2.   

    Thread.CurrentThread.CurrentCultureThread.CurrentThread.CurrentUICulturehttp://www.informit.com/articles/article.asp?p=29574&seqNum=6&rl=1
      

  3.   

    不行呀,,,
    在组件中调用的话是组件线程的CurrentCulture/CurrentUICulture,而不是调用者的
    CurrentCulture/CurrentUICulture例如:
    调用者
    System.Globalization.CultureInfo newCulture = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
    System.Threading.Thread.CurrentThread.CurrentUICulture = newCulture;Thread.CurrentThread.CurrentCulture
    这里是"en-US"组件中:
    Thread.CurrentThread.CurrentCulture ='zh-CN'.
      

  4.   

    ASP.NET中,只有一个线程,所以你需要知道设置CurrentCulture的次序,或者你需要在某个变量里放置这个Culture
      

  5.   

    还是不明白,能否给个具体的例子??我知道很冒寐的打觉您了,但是请您帮忙看一下,谢谢..
    我的机子是中文系统,区域设置为"zh-CN".我在asp.net中有以下代码:
    System.Globalization.CultureInfo newCulture = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
    System.Threading.Thread.CurrentThread.CurrentUICulture = newCulture;
    Response.Write(System.Thread.CurrentThread.CurrentCulture)
    这里是"en-US"
    然后载入我开发的组件.
    在组件中:
    string str=System.Thread.CurrentThread.CurrentCulture;
    调试跟踪了一下,发现str="zh-CN",如果是您所说的那样的话,这里应该是str="en-US"..
      

  6.   

    你在哪里设置的CurrentThread.CurrentCulture?你页面里的第一行<%@ Page ..%>设置是什么?
      

  7.   

    其实我也想到什么办法解决,就是把区域性信息放在某个其他的配置文件中,例如:web.config,或者其他的xml,ini,文本文件中也行,然后asp.net中和自己开发的组件中都去读取,不过我不想这样做,我想能不能直接在组件中获取到引用该组件的asp.net程序中设置的System.Threading.Thread.CurrentThread.CurrentCulture
      

  8.   

    if(!IsPostBack)
    {
    System.Globalization.CultureInfo newCulture = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
    System.Threading.Thread.CurrentThread.CurrentUICulture = newCulture;
    string str = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
    ...
    if(CJH.Tools.CheckData.IsInteger(tbNumber.Text))
    {
    ....
    }
    }
      

  9.   

    CJH.Tools为我写的组件,各个语言版本的资源文件都嵌入到该DLL文件中了..
      

  10.   

    sounds weird, how can the culture change in your server control?http://www.devx.com/dotnet/Article/6997/1954?pf=true
      

  11.   

    晕,我看了一下,好像只是把CultureInfo放在Cookies中呀....
    倒,我在申明一下..其实我也想到办法解决,就是把区域性信息放在某个其他的配置文件中,例如:web.config,或者其他的xml,ini,文本文件中也行,然后asp.net中和自己开发的组件中都去读取,不过我不想这样做,我想能不能直接在组件中获取到引用该组件的asp.net程序中设置的System.Threading.Thread.CurrentThread.CurrentCulture
      

  12.   

    show your code, also remove if (!IsPostBack)System.Globalization.CultureInfo newCulture = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
    System.Threading.Thread.CurrentThread.CurrentUICulture = newCulture;
    string str = System.Threading.Thread.CurrentThread.CurrentCulture.Name;