Telerik-based DLL does not load, due to enhancer(?) issues

338 Views Asked by At

I'm working on a C# solution, containing two projects, a client and a server.

Both are normally built using "Any CPU" (which means in my opinion) that they are build as 64-bit processes.

I'm facing different problems, most probably due to some enhancer issue, but I have no idea what this might be.

Problem 1: older problem

While building the client, now I get the following error message:

The specified assembly 'C:\Users\DDM\AppData\Local\Temp\_ptil_15736\Client_Program.Client.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.

Now, some efforts:

  • The mentioned directory C:\Users\DDM\AppData\Local\Temp\_ptil_15736 does not even exist.
  • Changing the build platform from "Any CPU" to "x86" sometimes makes the client work, sometimes not.

On the internet, I've found following URL, explaining something about 32-bit and 64-bit and some things about enhancers, whatever that might be.

Extra efforts:

In both my server application as my client application, I have quite some references to Telerik DLLs. Most have version "v4. ...", but Telerik.OpenAccess and Telerik.OpenAccess.35.Extensions and Telerik.OpenAccess.Runtime have version "v2.0.50727".

As far as enhancers is concerned, this is the place where I find them:

C:\<all_projects>\packages\Telerik.DataAccess.Fluent.2013.3.1320.1\tools\enhancer\enhancer.exe.config
C:\<all_projects>\packages\Telerik.DataAccess.Fluent.2013.3.1320.1\tools\enhancer\venhance.exe.config
C:\<all_projects>\packages\Telerik.DataAccess.Fluent.2016.2.822.1\tools\enhancer\enhancer.exe.config
C:\<all_projects>\packages\Telerik.DataAccess.Fluent.2016.2.822.1\tools\enhancer\venhance.exe.config

(I have no idea which ones of those are actually used.)

All of those "*enhance*.exe.config" files have the same content:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <!--The enhancer is compiled against .NET 4.0.-->
    <!--To be able to enhance an .NET 2.0 assembly please comment out the next line:-->
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

Having a further look at the mentioned URL, there is following quote:

Visual Studio starts the MsBuild.exe as 32-bit process

Well, I had a look the different "MSBuild.exe" files on my computer, and this is what I come up with:

C:\>dir /S /B "msbuild.exe"
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe
C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\MSBuild.exe
C:\Temp_Folder\Default\MSBuild.exe
C:\Temp_Folder\NativeImage\MSBuild.exe
C:\Windows\assembly\GAC_32\MSBuild\3.5.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\assembly\GAC_64\MSBuild\3.5.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\Microsoft.NET\assembly\GAC_32\MSBuild\v4.0_12.0.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\Microsoft.NET\assembly\GAC_32\MSBuild\v4.0_4.0.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\Microsoft.NET\assembly\GAC_64\MSBuild\v4.0_12.0.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\Microsoft.NET\assembly\GAC_64\MSBuild\v4.0_4.0.0.0__b03f5f7f11d50a3a\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
C:\Windows\WinSxS\amd64_msbuild_b03f5f7f11d50a3a_10.0.19041.1_none_fa6e7f402dbc0227\MSBuild.exe
C:\Windows\WinSxS\amd64_msbuild_b03f5f7f11d50a3a_3.5.19041.1_none_82a6b3679b68b331\MSBuild.exe
C:\Windows\WinSxS\amd64_msbuild_b03f5f7f11d50a3a_4.0.15805.0_none_dc3886319c616739\MSBuild.exe
C:\Windows\WinSxS\amd64_msbuild_b03f5f7f11d50a3a_4.0.15840.3_none_dc3389e19c65e13f\MSBuild.exe
C:\Windows\WinSxS\wow64_msbuild_b03f5f7f11d50a3a_4.0.15805.0_none_0606cd4b5dabfc56\MSBuild.exe
C:\Windows\WinSxS\wow64_msbuild_b03f5f7f11d50a3a_4.0.15840.3_none_0601d0fb5db0765c\MSBuild.exe
C:\Windows\WinSxS\x86_msbuild_b03f5f7f11d50a3a_10.0.19041.1_none_421bb61742382b2d\MSBuild.exe
C:\Windows\WinSxS\x86_msbuild_b03f5f7f11d50a3a_3.5.19041.1_none_268817e3e30b41fb\MSBuild.exe

How can I know which one is used and how can I replace this by a 64-bit MSBuild.exe?

Edit

While building my application, I see following warning, does anybody know what it means?

MSBUILD : OpenAccess Enhancer warning : No persistent classes found. Is the metadata information missing?

  1. What are persistent classes (in Telerik OpenAccess terminology)?
  2. What is the mentioned metadata, and where and how can I read/write it?

Problem 2: current problem

In my company, it is common to start with some kind of base classes, which have their objects stored in an SQL-server database. The last column in database of the base class is voa_class, showing the real class of the mentioned object.

Now I have a Vehicles base class and a subclass <Company>.Viastore.Server.Domain.ViastoreSrm, and in database I have a table, called Vehicles, containing an entry with voa_class <Company>.Viastore.Server.Domain.ViastoreSrm and another table ViastoreSrm, containing an entry with the same id value as the one from the Vehicles table (both id fields being equal allow both entries to be linked to each other).

In source code, I have following line:

namespace <Product>.<Customer>.Server
{
    ViastoreSrm viastore = database.GetData<ViastoreSrm>().FirstOrDefault();

Although this is standard (this way of getting data from the Telerik Openaccess database is used for more than ten years), now I get the following Exception:

System.ArgumentOutOfRangeException: Type is enhanced and registered, but not available from the database class meta data. This can be caused by a wrong connection id or configuration.
Parameter name: type
Actual value was <Product>.Viastore.Server.Domain.ViastoreSrm.
   at OpenAccessRuntime.ObjectScope.GetMetaData(Type type)
   at OpenAccessRuntime.ObjectScope.CheckPersistentType(Type type)
   at Telerik.OpenAccess.ExtensionMethods.Extent[T](IObjectScope scope)
   at Telerik.OpenAccess.OpenAccessContext.GetAllCore[T]()
   at Telerik.OpenAccess.OpenAccessContext.GetAll[T]()
   at <Product>.Server.OpenAccess.Database.GetData[T]()
   at <Product>.<Customer>.Agv.Server.Manager.CheckViastoreOrder(IDatabaseConnection database) in C:\...\<Customer>\<Product>.<Customer>.Agv.Server\Manager.Viastore.cs:line 53

As you see, the Exception message is talking about connection id (what connection id?), configuration (what part of the configuration?), ... but most of all that enhancer gets back in the picture!

I have the impression that that enhancer is responsible for a lot of bad behaviour of my application. As this code is working without problems on the PC of a colleague, I believe this enhancer should be something outside of the development environment, but what?

How can I understand this matter? What is that enhancer? How do I configure (or get of) it? ... and most importantly, how can I make sure that it does not hinder my development any more?

0

There are 0 best solutions below