C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference By Joseph Albahari, Ben Albahari
September 2007
Pages: 858


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Linqpad On Vista 64 With A 32-bit Assembly, 32-bit assemblies on a 64 bit system
mschwab
post Jun 8 2009, 07:03 PM
Post #1


New Member
*

Group: Members
Posts: 2
Joined: 15-May 09
Member No.: 18,143



Here's the scenario. I'm trying to access data in an Access 2007 db file. I can get this to work fine in Visual Studio using OLEDB with this provider... Provider=Microsoft.ACE.OLEDB.12.0
This works fine when compiled as a 32-bit dll. However, if I create a wrapper DLL and reference the 32-bit dll in LinqPad, then LinqPad throws the following.

An attempt was made to load a program with an incorrect format.

Well, a little research shows that message happens when you attempt to load a 32-bit dll into a 64-bit app.

It seems then, that Linqpad is runtime compiling itself as a 64-bit program since it's in a 64-bit environment, is this correct? Is it possible to force it compile as a 32-bit program so I can reverence native 32-bit dlls, perhaps with a command line switch?

To confirm this, I built the wrapper dll as a 64-bit program, and it throws the same error in a Visual Studio unit test. If I use the 64-bit wrapper dll in LinqPad then I get this...

InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Research shows that this message indicates that the Access 32-bit dll is being loaded by a 64-bit app.
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jun 10 2009, 05:52 AM
Post #2


Advanced Member
******

Group: Members
Posts: 215
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



You can hack LINQPad so as to force 32-bit execution with the corflags tool:

corflags /32bit+ /force linqpad.exe

Bear in mind that you'll have to repeat the process after a LINQPad update. (It's also possible that it may prevent LINQPad updates from loading, because the signature will be missing from the original).

Regards

Joe
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 22nd November 2009 - 05:08 AM