日期:2014-05-17  浏览次数:20834 次

[System.ArgumentException] = {"指定的命名连接在配置中找不到、非计划用于 EntityClient 提供程序或者无效。
下边的代码是 mvc models里边的, 我在winform里边调用这个静态方法,执行using (var db = new WEBVODEntities())就出错了。  错误信息:[System.ArgumentException] = {"指定的命名连接在配置中找不到、非计划用于 EntityClient 提供程序或者无效。

MVC里边很多地方有using (var db = new WEBVODEntities()),也没有错啊

请问该怎么办?

        /// <summary>
        /// 获取文档,指定count数量、status状态
        /// </summary>
        /// <param name="count">需要的文档数量</param>
        /// <param name="status">需要文档的状态</param>
        /// <returns></returns>
        public static List<Library> GetUploadBooks(int count=10,int status = 0)
        {
            using (var db = new WEBVODEntities())
            {
                return db.Library.Where(a => a.Status == status).OrderBy(a => a.PubDate).Take(count).ToList();
            }
 
        }



------解决方案--------------------
<connectionStrings>
    <add name="WEBVODEntities" connectionString="metadata=res://*
/Models.webvodEF.csdl
------解决方案--------------------
res://*/Models.webvodEF.ssdl
------解决方案--------------------
res://*/Models.webvodEF.msl;
provider=System.Data.SqlClient;provider connection string=&quot;Data Source=OA-
SER\SQL08;Initial Catalog=WEBVOD;Integrated Security=True;
MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  不要写在<appSettings>段里
------解决方案--------------------
cli_cppuhelper.dll有问题,文件损坏,32为系统用了64位的文件之类的原因,可能性比较多,不好猜