winform连接oracle时Oracle.DataAccess.dll版本问题 Silverlight
1.通用TestOracle.zip部署到iis上,或直接运行程序测试当前全局程序集
protected void Button1_Click(object sender, EventArgs e) { //OracleConnection con = new OracleConnection("Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = ip地址)(PORT = 1521)))( CONNECT_DATA =(SERVICE_NAME = orcl)));User Id=用户名;Password=密码;"); DbFactory.Init("Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = ip地址)(PORT = 1521)))( CONNECT_DATA =(SERVICE_NAME = orcl)));User Id=用户名;Password=密码;", DbTypeEnum.Oracle); OracleConnection con = (OracleConnection)DbFactory.GetDbCon(); con.Open(); //获取当前运行的dll的版本 Assembly assembly = Assembly.GetExecutingAssembly(); Response.Write(con.GetType().Assembly.FullName + "<br/>"); con.Clone(); //获取自己封装的数据访问版本 //DbHelper db = DbFactory.GetInstance(); //Response.Write(db.GetType().Assembly.FullName + "<br/>"); ////获取ODP.Net的版本 //DbConnection cnn = DbFactory.GetDbCon(); //Response.Write(cnn.GetType().Assembly.FullName + "<br/>"); //var r = db.ExecuteReader(cnn, CommandType.Text, "select * from BJSW_RSVR_R t"); //Response.Write(r.HasRows); //cnn.Close(); //方式二 //DbHelper db = DbFactory.GetInstance(); //var r = db.ExecuteReadEntity<X>(DbFactory.ConnectionString, CommandType.Text, "select * from HY_GPH_A", (reader) => //{ // Response.Write(reader.HasRows); // if (reader.Read()) // { // List<X> l = new List<X>(); // l.Add(new X() { Name = reader[0].ToString() }); // return l; // } // else // { // return null; // } //}); //方式三 //TestDao dao = new TestDao(); //var list = dao.QueryList(); //Response.Write(list == null?"没有数据":"有数据"); }
2.将winform生成的版本修改为x64,一般服务器都是64位
3.在app.config中添加Oracle.DataAccess.dll版本
<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" culture="neutral" /> <bindingRedirect oldVersion="4.112.3.0" newVersion="2.112.1.0" /> </dependentAssembly> </assemblyBinding> </runtime> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> </configuration>
4.通过TestOracle.zip得到Oracle.DataAccess版本,将版本添加到newVersion中
5.获取值在程序集中查看Oracle.DataAccess版本
6.Test
7.silverlight 在web.config中添加配置
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" culture="neutral" /> <bindingRedirect oldVersion="4.112.3.0" newVersion="2.112.1.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>