Thanks Guys
The exception I get doesn't output anything, sorryI should have clarified that earlier. I tried building it under x86 and I received the same thing (exception which is supposed to be a stack trace but nothing it only displays the method name). I'll give a little more explanation.
The vendor we use is Intergraph, the have a utility they have created to keep two databases in sync. All of the applications run on to of this so that you can have redundant databases, the insync layer is called rado, it basically writes to two databases then commits and can detect which one is primary, secondary and if one is down or now and behaves accordingly. We required a web service to access this database, we tried to write our own code to manage the dual systems but it would not work properly and cause the Intergraph applications to fail. Intergraph told use we could create some c# code to use their code but that they did not support this and wouldn't be much help if we ran into problems. So we created the code and everything worked fine. The dll's we require in the project are the 2 interop Interop.ADBODB.dll and Interop.REDUNADOLib.dll. I have been told by one of our developers that the Interop ones should be fine as they should be .net wrappers around COM objects, its most likely dependancies for the Interop's that are not loaded. I am not sure if this is the case and he said that this should be the next avenue we try.
In my source code I simply added a reference to the dll's and compiled my code. I have included the source code don't know how much that will help or not but maybe we will get one step further. This is just a quick connectivity test so this is the only class that is being called from a Program.cs class. The exception is
The type initializer for 'RadoTest.SimpleTest' threw an exception
at RadoTest.SimpleTest.TryToConnectToDB()
at RadoTest.Program.Main(String[] args)
using
System;
using
System.Collections.Generic;
using
System.Text;
using
Microsoft.Win32;
using
REDUNADOLib;
using
ADODB;
namespace
RadoTest
{
public class SimpleTest
{
private static string mDBConfig;
private static string SQLStmt;
private static Field Fld;
private static long RowCount;
private static string errStr;
private static RADOConnection RADO = new RADOConnectionClass();
private static IRADOConnection IRADO;
public static void TryToConnectToDB()
{
bool bRetVal = false;
Recordset records;
Int32 recordsAffected = 0;
object myRecordsAffected = recordsAffected;
string num_1;
Connect();
SQLStmt =
"select num_1 from cad.aeven where rownum < 15";
records = RADO.Execute(SQLStmt,
out myRecordsAffected,0);
if(records.EOF)
{
Console.WriteLine("No data found");
}
while(!records.EOF)
{
num_1 = records.Fields[
"num_1"].Value.ToString();
Console.WriteLine("num_1:" + num_1);
records.MoveNext();
}
records.Close();
Console.ReadLine();
}
public static string GetDBConfig()
{
string dbconfig;
RegistryKey ourKey = Registry.LocalMachine;
ourKey = ourKey.OpenSubKey(
@"SOFTWARE\Intergraph Public Safety\Configurations");
dbconfig = ourKey.GetValue(
"Default").ToString();
return dbconfig;
}
public static bool Connect()
{
bool bRetVal = false;
string connectString = "DBConfig=" + GetDBConfig();
Console.WriteLine("Connecting to DB ..."+connectString);
IRADO = (
IRADOConnection)RADO;
RADO.Mode =
ConnectModeEnum.adModeReadWrite;
RADO.Open(connectString,
"caduser","caduser",-1);
if (IRADO.RedundancyState > 0)
{
bRetVal =
true;
Console.WriteLine("DB Connection OK");
}
else
{
Console.WriteLine("DB Connection Failed");
}
return bRetVal;
}
public static void Disconnect()
{
if (IRADO.RedundancyState > 0)
{
RADO.Close();
}
}
}
}