当前位置:编程学习 > C#/ASP.NET >>

webservice 读取资源文件出错,请高手们帮帮忙,小弟感激万分呀!

我创建了一个webservice工程.然后加了一个资源文件,命名为Service.resx,然后在资源文件里输入字符串资源,命名为String1 
在HelloWorld方法中调用出错! 
[WebMethod]
public string HelloWorld() 
    { 
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Service)); 
        
        return resources.GetString("String1"); 
    } 

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Service.resources" was correctly embedded or linked into assembly "App_Code.tekdharx" at compile time, or that all the satellite assemblies required are loadable and fully signed.
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at System.Resources.ResourceManager.GetString(String name)
   at Service.HelloWorld() in d:\WebSite4\App_Code\Service.cs:line 22

这个要怎么解决呀! 
谢谢~!~!~! --------------------编程问答-------------------- 首先在你的项目里添加引用,添加这个System.Configuration,然后在类里导入using System.Configuration,最后private static string connstr = ConfigurationManager.AppSettings["conn"];这样就可以拿到资源文件里的东西了 --------------------编程问答-------------------- 还要这样配置呀!
我试一下,太谢谢你的回答了.
谢谢你!! --------------------编程问答-------------------- zxjzmh2你那个是读取web.config里的资源数据,而我要读取的是resx资源文件里的资源.
看一下还有法子解决吗??
谢谢你了. --------------------编程问答-------------------- resources 添加 有误 --------------------编程问答-------------------- 那要怎么添加呀,请教 --------------------编程问答-------------------- mark --------------------编程问答--------------------
补充:.NET技术 ,  Web Services
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,