Problem migrating SQL2005 CLR Assemblies from 32 to 64 bit environment

Posted on 2012-08-21
Last Modified: 2012-08-22

I am currently in the process of migrating our database server (which is Windows Server 2003 32-Bit, SQL2005) over to a VM environment which will be Windows 2008 R2 64-Bit, SQL 2005 64 Bit.

One of the issues I am currently facing is that I am having difficulty with the database integration which has been developed using a CLR Assembly (C#). This assembly when called uses OLE DB  to connect to a legacy Visual FoxPro Database (V7), using the VFPOLEDB provider, and updates data in the database.

Under testing the new environment, this database integration fails. The OLEDB driver reports the following error any time an attempt is made to update the data :

“The 'VFPOLEDB.1' provider is not registered on the local machine. “

I did some further investigation and found out that the OLEDB driver is not supported in a 64-bit environment, but could be run in a 32-bit environment running under  WOW64. I created a small test application in C# that would write some data using the OLEDB driver, complied it for x86 CPU and ran the test application. The test application ran fine and updated the data in the Visual FoxPro Application.

My next step is then to re-compile the CLR Assembly for x86 CPU and import it back into SQL2005. I do this without any issues but when I then try and then do an update I get the following message from SQL Server :

Msg 10314, Level 16, State 11, Procedure usp_UpdateFoxPro, Line 45
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65542. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'foxprointegration, Version=, Culture=neutral, PublicKeyToken=b23e91ab0ea90eca' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
The statement has been terminated.

(I also get the same error when creating a small test CLR Assembly compiled for x86 CPU)

My question is how can I fix this error, or is it not possible to run 32-bit CLR Assemblies from a 64-Bit SQL Server ?

I would really like to get this solved as the whole point of moving to a 64 bit environment is to take advantage of the additional memory we can put on the server. If I have to still run in a 32-bit environment it kind of defeats the point of doing the migration, other than the fact the hardware needs replacing this year!
Question by:chriscboy
    LVL 44

    Accepted Solution

    unfortunately it is not possible to call/use a 32bit dll in a 64bit process and vice versa:

    Perhaps you may use have a look at the Sybase product:
    They have included 64-bit ODBC and OleDB driver for VFP.


    Author Closing Comment

    Thanks for confirming my suspicions with this. Looks like im going to have to bite the bullet and just use the 32-bit version of sql server to keep our database integration working.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now