[Mono-list] System.DllNotFoundException: oci

Gilles FAVIER gilles.favier2605@wanadoo.fr
Tue, 12 Apr 2005 12:53:36 +0200 (CEST)


Hi everybody i am back with ASPX issues...

To make my problem very clear the explanation are not going to be so long but i will all my code below. I kept as many variable as default to simplify the explanation. If any other information is needed to understand my problem feel free to ask.

I am running Mono 1.0.6 (installed as root user)with all neede packages and i manage without any trouble to display the Mono Sample web pages.
I am on a Virtual Machine (ran with VMWARE) under RedHat Enterprise Server 3.0 and i have installed the Oracle Client 9.2.0.4 with all needed packages to get it to work. ( i can also : "sqlplus XXX/XXX@XXX" and ask some SELECT * to my base)

1--
I can ping my base with "tnsping" as Oracle user. If i use the code detailed in test.cs and i compile it with the command line : (as a root user)
mcs test.cs /r:System.dll  /r:System.Data.dll  /r:System.Data.OracleClient.dll
and then as Oracle user i type :
mono test.exe
and i get the expected result.

2--
If i take the same code and i put it in webform (see all web code below) and then i run :
mcs /t:library /out:WebTest.dll -r:System -r:System.Data -r:System.Drawing -r:System.Web -r:System.Data.OracleClient AssemblyInfo.cs Default.aspx.cs Global.asax.cs
(I thank again the list for helping me on this last one and also Seb Pouliot)
then i copy paste everything in the right directory on .../doc/xsp/test and in Firefox i put : http://localhost/demo (with the configuration given in the INSTALL of mod_mono)
I see the first page and when i click on GO, i get the following error message : 

--------------- start ERROR MESSAGE -----------------------
Description: Error processing request.

Error Message: HTTP 500.

Stack Trace:

System.DllNotFoundException: oci
in <0x00053> (wrapper managed-to-native) OciNativeCalls:OCIEnvCreate (intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
in <0x00020> System.Data.OracleClient.Oci.OciCalls:OCIEnvCreate (intptr&,System.Data.OracleClient.Oci.OciEnvironmentMode,intptr,intptr,intptr,intptr,int,intptr)
in <0x0005d> System.Data.OracleClient.Oci.OciEnvironmentHandle:.ctor (System.Data.OracleClient.Oci.OciEnvironmentMode)
in <0x0003c> System.Data.OracleClient.Oci.OciGlue:CreateConnection (System.Data.OracleClient.OracleConnectionInfo)
in <0x0002b> System.Data.OracleClient.OracleConnection:Open ()
in <0x0004f> (wrapper remoting-invoke-with-check) System.Data.OracleClient.OracleConnection:Open ()
in <0x00094> WebTest._Default:BTGO_Click (object,System.EventArgs)
in <0x00069> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
in <0x00081> System.Web.UI.WebControls.Button:OnClick (System.EventArgs)
in <0x00058> System.Web.UI.WebControls.Button:System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (string)
in <0x00016> System.Web.UI.Page:RaisePostBackEvent (System.Web.UI.IPostBackEventHandler,string)
in <0x0003e> System.Web.UI.Page:RaisePostBackEvents ()
in <0x002c3> System.Web.UI.Page:InternalProcessRequest ()
in <0x000c2> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext)
in <0x002eb> ExecuteHandlerState:Execute ()
in <0x00084> StateMachine:ExecuteState (System.Web.HttpApplication/IStateHandler,bool&)
--------------- END ERROR MESSAGE -----------------------

What is really weird is that if i take the WebTest.dll and i replace the one created by visual studio in my ../siteweb/bin directory ... IT WORKS... i have the expected answer of my query...
Which makes me think that according to 1-- i can connect to my base and my tnsnames.ora is good! and according to 2-- the dll created is working. 
Why isn't it working under Linux??



-----------------------------------------------------------------
--------------------- START CODE test.cs ----------------------

 using System;
 using System.Data;
 using System.Data.OracleClient;

 public class Test
 {
    public static void Main (string[] args)
    {
        string connectionString =
                                "Data Source=XXXX;User ID=XXXXX;Password=XXXXX;";
                        OracleConnection dbcon = null;
                        dbcon = new OracleConnection (connectionString);
                        dbcon.Open ();
                        OracleCommand dbcmd = dbcon.CreateCommand ();
                        string sql = "SELECT COUNT(*) AS COUNTER FROM T_USER";
                        dbcmd.CommandText = sql;
                        Console.WriteLine(sql);

                        OracleDataReader reader = dbcmd.ExecuteReader ();

                        while(reader.Read())
                        {
                        Console.WriteLine((string) reader["COUNTER"].ToString());
                        }

                        reader.Close ();
                        reader = null;
                        dbcmd.Dispose ();
                        dbcmd = null;
                        dbcon.Close ();
                        dbcon = null;
    }
 }

------------------ END CODE test.cs------------------------


----------------- START CODE Defalut.aspx ------------------------
<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="WebTest._Default" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>Default</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<P>
				<asp:Label id="LBSQL" runat="server">Label</asp:Label><BR>
				<asp:Button id="BTGO" runat="server" Text="GO "></asp:Button></P>
			<P>
				<asp:Label id="LBResult" runat="server" BackColor="#FFFFC0">Label</asp:Label></P>
		</form>
	</body>
</HTML>
----------------- END CODE Default.aspx ------------------------

----------------- START CODE Defalut.aspx.cs ------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;

namespace WebTest
{
	/// <summary>
	/// Summary description for _Default.
	/// </summary>
	public class _Default : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button BTGO;
		protected System.Web.UI.WebControls.Label LBResult;
		protected System.Web.UI.WebControls.Label LBSQL;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.BTGO.Click += new System.EventHandler(this.BTGO_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void BTGO_Click(object sender, System.EventArgs e)
		{
			LBResult.Text = "";
			LBSQL.Text =  "SELECT COUNT(*) AS COUNTER FROM T_USER";

			string connectionString = 
				"Data Source=XXXX;User ID=XXXXX;Password=XXXXX;";
			OracleConnection dbcon = null;
			dbcon = new OracleConnection (connectionString);
			dbcon.Open ();
			OracleCommand dbcmd = dbcon.CreateCommand ();
			string sql = LBSQL.Text;
			dbcmd.CommandText = sql;			
	
			OracleDataReader reader = dbcmd.ExecuteReader ();
			
			while(reader.Read()) 
			{
				LBResult.Text += (string) reader["COUNTER"].ToString() + "<BR>";
			}

			reader.Close ();
			reader = null;
			dbcmd.Dispose ();
			dbcmd = null;
			dbcon.Close ();
			dbcon = null;
		}
	}
}

----------------- END CODE Defalut.aspx.cs ------------------------

----------------- START CODE Global.asax------------------------
<%@ Application Codebehind="Global.asax.cs" Inherits="WebTest.Global" %>

----------------- END CODE Global.asax------------------------

----------------- START CODE Global.asax.cs ------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

namespace WebTest 
{
	/// <summary>
	/// Summary description for Global.
	/// </summary>
	public class Global : System.Web.HttpApplication
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		public Global()
		{
			InitializeComponent();
		}	
		
		protected void Application_Start(Object sender, EventArgs e)
		{

		}
 
		protected void Session_Start(Object sender, EventArgs e)
		{

		}

		protected void Application_BeginRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_EndRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_AuthenticateRequest(Object sender, EventArgs e)
		{

		}

		protected void Application_Error(Object sender, EventArgs e)
		{

		}

		protected void Session_End(Object sender, EventArgs e)
		{

		}

		protected void Application_End(Object sender, EventArgs e)
		{

		}
			
		#region Web Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.components = new System.ComponentModel.Container();
		}
		#endregion
	}
}


----------------- END CODE Global.asax.cs ------------------------

----------------- START CODE AssemblyInfo.cs ------------------------
using System.Reflection;
using System.Runtime.CompilerServices;


[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]		


[assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

----------------- END CODE AssemblyInfo.cs ------------------------

----------------- START CODE Web.config ------------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    
  <system.web>

    <!--  DYNAMIC DEBUG COMPILATION
          
    -->
    <compilation 
         defaultLanguage="c#"
         debug="true"
    />

    <!--  CUSTOM ERROR MESSAGES
          
    -->
    <customErrors 
    mode="RemoteOnly" 
    /> 

    <!--  AUTHENTICATION 
          
    -->
    <authentication mode="Windows" /> 

	<!--  AUTHORIZATION 
          
    -->

    <authorization>
        <allow users="*" /> <!-- Allow all users -->
            <!--  <allow     users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny      users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
    </authorization>

    <!--  APPLICATION-LEVEL TRACE LOGGING
          
    -->
    <trace
        enabled="false"
        requestLimit="10"
        pageOutput="false"
        traceMode="SortByTime"
		localOnly="true"
    />

    <!--  SESSION STATE SETTINGS
          
    -->
    <sessionState 
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false" 
            timeout="20" 
    />

    <!--  GLOBALIZATION

    -->
    <globalization 
            requestEncoding="utf-8" 
            responseEncoding="utf-8" 
   />
   
 </system.web>

</configuration>

----------------- END CODE Web.config ------------------------