Hi,
I am trying to display XML from Oracle in browser. It is working well in my local machine (Windows XP). But it is throwing me system. BadImageexception after deploying the code on IIS7.0
I am using providerName="System.Data.OleDb"
Please help me where I am doing wrong.
CODE:
private void DisplayXML(Int16 id)
{
string connectionString = WebConfigurationManager.ConnectionStrings["oracledev"].ConnectionString;
using (OracleConnection con = new OracleConnection(connectionString))
{
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT xml FROM TABSDORDERAUDITLOG WHERE ID=" + id;
var xmldata = Convert.ToString(cmd.ExecuteScalar());
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
Byte[] bytes = encoding.GetBytes(xmldata);
using (MemoryStream memStream = new MemoryStream())
{
memStream.Write(bytes, 0, bytes.Length);
Response.Clear();
Response.ContentEncoding = Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "");
Response.AppendHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
}
if (con.State == ConnectionState.Open)
con.Close();
}
}
}
Error Message:
Server Error in '/QueryUIApp' Application.
--------------------------------------------------------------------------------
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)]
Oracle.DataAccess.Client.OpsTrace.GetRegTraceInfo(UInt32& TrcLevel, UInt32& StmtCacheSize) +0
Oracle.DataAccess.Client.OraTrace.GetRegistryTraceInfo() +104
Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString) +97
QueryAuditUI.SDAuditMessage.DisplayXML(Int16 id) +109
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428