我模拟 MS petshop3.0 重新写啦一编
在自已机器上运行一切正常(在我机器上开发的) 把所有程序移值到另外的机器上就出现误
 误码提示
  Exception decrypting. Decryption failed. 该项不适于在指定状态下使用。 
堆栈跟踪: 
[Exception: Exception decrypting. Decryption failed. 该项不适于在指定状态下使用。
]
   Utility.DataProtector.Decrypt(Byte[] cipherText, Byte[] optionalEntropy)
   Utility.ConnectionInfo.DecryptDBConnectionString(String InputConnectionString)
   SQLServerDAL.SQLHelper..cctor()[TypeInitializationException: “SQLServerDAL.SQLHelper”的类型初始值设定项引发异常。]
   SQLServerDAL.SQLHelper.ExecuteDataset(String p_commandText, CommandType p_CommandType, SqlParameter[] p_commandParameters) +0
   SQLServerDAL.SystemModule.GetModule(String p_userCode)
   BLL.SystemModule.GetModule(String p_userCode)
   WebAudit.Test.Page_Load(Object sender, EventArgs e) in d:\web\webaudit\test.aspx.cs:23
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731

解决方案 »

  1.   

    调用SqlHelper的代码里做了两件事。第一,在Web.config里,我创建了一个appSettings区,它可以通过System.Configuration类来访问:
    <appSettings>
     <add  key="mainConnectionString"
    value="Data Source=myDb;Initial Catalog=database;
    user id=user1; password=pass1"/>
    </appSettings>第二,使用这个配置文件里的关键字对connString变量进行了初始化。要记住在你的组件里参照System.Configuration命名空间。
    using System.Configuration;
    string connString =
    ConfigurationSettings.AppSettings["mainConnectionString"];
      

  2.   

    看看这里是不是sql server的地址或密码的问题
      

  3.   

    地址或密码绝对是没有问题 我在开发的时候连的就是我移值那台机器上的sql server 为什么会出现这种情况