This is a migrated thread and some comments may be shown as answers.

Unable to compile 64-bit assembly that contains OpenAccess ORM

2 Answers 185 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matt
Top achievements
Rank 1
Matt asked on 13 Aug 2013, 07:11 PM
Hello,

When I attempt to compile my assembly for a 64-bit platform I get the following error:

The specified assembly [my dll] cannot be loaded.

The problem might be that the enhancer runs in a .NET framework 2.0 vm and the assembly to enhance is a .NET 4.0 assembly
or you are trying to enhance a x86 assembly in a 64 bit process or a x64 assembly in a 32 bit process.

Please change the required version inside the enhancer.exe.config or venhance.exe.config or switch to 'Any CPU' for this project.


I'm using VS2010 and OpenAccess ORM Q2 2013 SP1. I do not get this error when I compile for a 32-bit platform.  Does this mean that OpenAccess ORM cannot be used in a 64-bit assembly?

In addition, 'Any CPU' is not an option I can use due to dependencies I need to use in my application.

2 Answers, 1 is accepted

Sort by
0
Kaloyan Nikolov
Telerik team
answered on 16 Aug 2013, 07:49 AM
Hello Matt,

The reason for this error message is that Visual Studio starts the MsBuild.exe as 32-bit process. In this context the Enhancer.exe is being executed and it loads your assembly in order to obtain the metadata and inject the code needed to make your entities persistence capable. Your assembly is compiled as x64 and it cannot be loaded in 32-bit process. This issue appears only compile time. 

To avoid this problem I would suggest you to move you data access layer (the entity classes and the OpenAccess Context) in separate project. This project you can compile as Any CPU. It will be enhanced correctly and later you can reference if from any project, regardless its platform (x32, x64 or Any CPU). Runtime OpenAccess ORM can work both in 32-bit and  64-bit processes.

I hope this helps. Please do not hesitate to get back to us if you have any other questions.
 

Regards,
Kaloyan Nikolov
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Matt
Top achievements
Rank 1
answered on 16 Aug 2013, 03:28 PM
Thank you for the explanation!  Your suggestion solved my issue perfectly.
Tags
Development (API, general questions)
Asked by
Matt
Top achievements
Rank 1
Answers by
Kaloyan Nikolov
Telerik team
Matt
Top achievements
Rank 1
Share this question
or