.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > Older .NET application not working on 64 bit OS
 

Older .NET application not working on 64 bit OS

I created a simple testing tool to see if we can connect to a database. This tool simply uses some 3rd party dll's (rado.dll, Interop.ADODB.dll, Interop.REDUNADOLib.dll) to connect to a databasethat is configured in the registry. Its a simple exe testing connectivity. When I run this exe on 32-bit operations systems (Win2k3) it works fine but when I put it on Win2K3 x64 or Win2k8 x64 it doesn't work I get an exception. I have registered the rado.dll in system32 and SysWow64, the dll registered fine, tried to register the Interop ones and I get the DllRegisterServer entry point not found error.

I do not know how to get this application working.
phoenixsilver
Your assembly was probably built targetting AnyCPU, not x86. However, it's probably trying to load a native 32bit resource.

You can correct this by either rebuilding, and explicitly targetting Win32/x86. Alternatively, you can use corflags.exe to convert the application to a 32bit application, by doing:

corflags.exe myAssembly.exe /32Bit+

For details, see MSDN for CorFlags Conversion Tool .

Reed Copsey, Jr. - http://reedcopsey.com
Reed Copsey, Jr.
Reed is mostlikely right, if this however not solves your problem feel free the share the actual exception with us, 'an exception' is not terribly helpfull in trying to trackdown your problem.
Ray M_

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();

}

}

}

}

phoenixsilver
It sounds like the Intergraph depdendency is probably not being installed correctly on the 64bit systems. If they have a 64bit version, it may be that it's installing a 64bit version (and not the 32bit version your code is expecting).

Reed Copsey, Jr. - http://reedcopsey.com
Reed Copsey, Jr.
Oh yeah forgot to say they DON'T have a 64 bit version of the application and they don't support any of their applications in 64 bit as of yet. Thanks guys for your help.
phoenixsilver
You'll need to take a look at the InnerException property of that exception, it tells you what really went wrong.

Hans Passant.
nobugz

Hello everyone

Apart from Hans and Reed's great suggestions, here are my thoughts:

1. Because the third party companyprovides onlythe 32bit component, and because the component is in-process, please make sure that your app targets 32bit platform, instead of the default "Any CPU".

2. In your first message, you mentioned that
I have registered the rado.dll in system32 and SysWow64
Do you mean that the dll was registered twice on the 64bit machine? The second registration of the dll will overwrite the first one. Also, please note that it's generally not recommended to register a 3rd party component into System32 or SysWow64 directory. Please try registering the compoent in theProgram Files directory instead, and test the app again.

BTW, does radio.dll depend on any other third party modules that are missing in the 64bit machine?

3. Your pasted callstack of the exception is not complete:
at RadoTest.SimpleTest.TryToConnectToDB()
at RadoTest.Program.Main(String[] args)
It should be some frame called by TryToConnectToDB that causes the exception. Could you please print the complete call-stack?


Regards,
Jialiang Ge


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Jialiang Ge [MSFT]

Ok,

I build the application as a 32 bit application and it did not work.

I realized that I did not require the rado.dll for the application to work so I unregistered the dll. My application only requires the two Interop dll's.

I added the inner exception stack trace to the code and did not receive any meaningful information. But I included the info below. My feeling is that the problem lies with the Interop dll's but I can't be certain. I unfortunately don't know if there are any depenancies with the rado.dll anyhow.

The type initializer for 'RadoTest.SimpleTest' threw an exception
at RadoTest.SimpleTest..cctor()
at RadoTest.SimpleTest.TryToConnectToDB()

at RadoTest.Program.Main(String[] args)

phoenixsilver
Hello

I realized that I did not require the rado.dll for the application to work so I unregistered the dll. My application only requires the two Interop dll's.

The interop dlls are simply the bridge between your .NET code and the COM components. They don't do any real work but transfer the calls between .NET and COM. In other words, solely adding the interop dlls is not enough. You need to register the COM components that do the real work.

In this case, you use two interop dlls:
Interop.ADODB.dll, Interop.REDUNADOLib.dll
The former is the interop assembly for a builtin ADODB component. It should have been register on all windows system. Thus you do not need to register the COM component again.
The latter appears to be a interop assembly for a third party COM component (possibly the radio.dll). You need to make sure that the component is registered on the machine.

To help you better understand Interop dlls, please refer to these article:

http://msdn.microsoft.com/en-us/library/z6tx9dw3.aspx
http://www.codeproject.com/KB/COM/cominterop.aspx
http://msdn.microsoft.com/en-us/magazine/cc163494.aspx

Regards,
Jialiang Ge
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Jialiang Ge [MSFT]

You can use google to search for other answers

Custom Search

More Threads

• Debugging under VS 2005 beta 2 for C++ and MASM64
• Is it better to buy 64-Bit pc?
• just in time debugger
• avifil32.dll support for 64 bit machine
• 64bit Memory Limits!?!
• 64bit COM object with 64Bit .net
• Force 64 bit ints?
• fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'AMD64'
• Memory Error in vs2008
• DEVMGR.DLL problem under XP 64