views:

302

answers:

2

This one’s a head scratcher. Here’s the deal.

While deploying a beta copy of an ASP.NET application built with Delphi 2007 for .NET to a test server I encountered an odd problem. The application was unable to start because it could not load the correct version of an ADO.NET data provider that I was using.

Only by including a version of the old assembly in the bin directory would the application run. However, I don’t want to be tied to this older .NET data provider, so I am determined to find a solution to this problem.

I originally compiled the project with the .net data provider assembly used as Copy Local, which should have caused Delphi to use a copy of that version of the assembly that I selected when I added it to the References folder in the Project Manager. The actual assembly that I selected was version 9.10.2.0, and that is the version of the assembly that appears in the bin directory, along with the application. However, at runtime the application was trying to bind to an earlier version of the same assembly, 9.0.2.7.

(Actually, this problem occurs whether or not I use the GAC version of Copy Local, so I don’t think this is the issue.)

While investigating this problem I created a new project, and added a reference to the 9.10.2.0 assembly. Still, both the .NET 2.0 Configuration Utility and Reflector showed that the application compiled with a reference to the 9.0.2.7 assembly.

Inspecting the GAC I saw that both 9.0.2.7 and 9.10.2.0 versions were registered. Attempting to remove the 9.0.2.7 version fails, since that version of the provider was still referencing the assembly in the GAC.

I went into the registry and manually removed all references to the 9.0.2.7 provider. I then was able to delete it from the GAC. This didn’t change anything. Removing the assembly from an existing application and then adding the 9.10.2.0 version back, then compiling, still resulted in the wrong assembly information being inserted into the application. As before, creating a new application that referenced the 9.10.2.0 assembly didn’t work, as a reference to 9.0.2.7 was still being inserted into the executable.

I’ve checked the Delphi library search path. I also removed every instance of the old assembly files from the machine altogether (including from the ASP.NET Temporary Files directory). I still got the problem. I tried using Issam Ali’s AppManifest utility to manually adjust the manifest, but apparently it does not support ASP.NET applications in Delphi 2007 for .NET.

So, the GAC no longer contains references to 9.0.2.7, there are no references to it in the registry, there are no paths to the old provider directory in the project or Delphi options dialogs, the old provider assembly is not on the file system, and 9.0.2.7 does not appear in any of the project files. Nor does it appear in web.config, machine.config, or any other file I checked. Nonetheless, Delphi insists on using this version of the assembly anytime I reference the 9.10.2.0 version of the assembly. (Yes, I restarted Delphi, and also restarted the Virtual Machine in which this development was being performed.)

Even after uninstalling the 9.10.2.0 data provider (the older one was already uninstalled), and reinstalling it, adding the data provider reference to an application results in the runtime application attempting to load the old provider (even though no reference to the old provider apparently remains in the system).

I’ve tried other solutions (which are worth mentioning here), but none worked. Anybody seen this? I am going to continue working on this problem, but I’d love to hear suggestions. I just can’t get Delphi to stop inserting the old assembly information into the project.

For grins I’m including the error log from the failure. This log essentially duplicates the information I get from the fusion log. This log is from one of the simple apps I created after removing the 9.0.2.7 assembly from the GAC. Notice that it’s looking for the old version of the provider from the outset.

Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll Running under executable c:\windows\microsoft.net\framework\v2.0.50727\aspnet_wp.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: User = TRAINING8A\ASPNET LOG: DisplayName = Advantage.Data.Provider, Version=9.0.2.7, Culture=neutral, PublicKeyToken=e33137c86a38dc06 (Fully-specified) LOG: Appbase = file:///C:/Inetpub/wwwroot/TestAdsVer2/ LOG: Initial PrivatePath = C:\Inetpub\wwwroot\TestAdsVer2\bin

Calling assembly : TestAdsVer2, Version=1.0.3572.17384, Culture=neutral, PublicKeyToken=null.

LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Inetpub\wwwroot\TestAdsVer2\web.config LOG: Using host configuration file: c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: Advantage.Data.Provider, Version=9.0.2.7, Culture=neutral, PublicKeyToken=e33137c86a38dc06 LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/testadsver2/07545aea/3d068a5/Advantage.Data.Provider.DLL. LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/testadsver2/07545aea/3d068a5/Advantage.Data.Provider/Advantage.Data.Provider.DLL. LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/TestAdsVer2/bin/Advantage.Data.Provider.DLL. WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated

This has gone on so long that the comments that I added to LanceSC's answer are no longer showing. But I do thing this is an interesting item that I want to address.

Here's my last two comments to LanceSC

  1. The installation that exhibited this behavior is in a VM that is no longer functioning. Another developer I know experienced this same problem. The solution was to abandon the installation. I feel that something in the installer of the particular version of this .NET data provider left some strange artifact that produced the problem. It does not happen with any other build of this data provider. I am no longer pursuing an answer to this question.

  2. Spoke too soon. A colleague of mine, today (March 5, 2010), encountered this same error, with a slightly earlier version of this same .NET data provider (9.0.2.1). He is now in the same position I was. He cannot run his application with any version of the data provider, save the old one. That assembly was being used as a local copy, and the old version is not in the gac. Using his machine, we ran the run MSBuild with the verbose option. The build worked fine with no errors. Nonetheless, the compile application failed to run, having failed to find the old version of the provider.

Summary

My colleague resigned himself to reinstalling Delphi 2007 (fortunately, he was working in a VM, and had a second VM with Delphi 2007 in which the offending .NET data provider had never been installed. This was also my tactic.

At this point, I have concluded that this problem is not solvable. Nonetheless, I am leaving this question open for another week or so. If no feasible solution is proposed in the next few weeks, I will close this question.

In the meantime, I have asked my colleague to preserve the VM with the misbehaving provider, in order to test any solution or investigation that is proposed.

+1  A: 

Have you tried grep'ing the Delphi and .NET framework directories for 9.0.2.7 to see if it is in a config file somewhere?

Something like:

grep -d 9\.0\.2\.7 *.xml

Other places you might search:

  • search the project files for 9.0.2.7
  • registry search for 9.0.2.7, and a search using the public token
  • If this app uses the BDP you might also search the BDP config files
Jeremy Mullin
I've searched everything I can think of. Can't find 9.0.2.7 anywhere (at least, any more).
Cary Jensen
Did you look in the project.dproj file? I created a delphi for .net asp.net application and found the referenced assembly info in my project.dproj file.
Jeremy Mullin
Yes I did. The only references there point to the directory where the 9.10.2.0 version of the assembly is located. (The 9.0.2.7 version assembly, when it was installed, appeared in a different folder than the 9.10.2.0 version.)
Cary Jensen
+3  A: 

Delphi 2007 uses MSBuild to perform the actual builds; however, the code in their product that syncs changes between the IDE and MSBuild is very brittle. My suspicion is that the build files are out of sync with the IDE. An easy way to update them is as follow:

Open your registry editor go to

HKEY_LOCAL_MACHINE\SOFTWARE\Borland\BDS\5.0\Globals

Change the value of ForceEnvOptionsUpdate to 1.

Open the RAD Studio IDE.

In order to confirm my suspicion you need to locate the files that Delphi.NET feeds to MSBuild. They are located somewhere under the current user's profile. You may also want to look at options in the Delphi help to have it do a verbose MSBuild output.

LanceSc
Thank you for the suggestion. I'll take a look and report back what I discover.
Cary Jensen
I looked at the registry, and found that the ForceEnvOptionsUpdate key was absent. I added this key with the 1 string value (the 2007 readme.txt mentions that this is a string value). This still had no effect.I assume that MSBuild uses the dproj file. I didn't see any reference there that should have had an impact. I also searched all files in the .NET framework dir, the project dir, and the RAD Studio 5.0 dirs, and Documents and Settings dirs for 9.0.2.7 with no luck. I included hidden and systems files in this search.Still scratching my head.
Cary Jensen
By then way, I searched the entire hard drive for 9.0.2.7. Search found some matches. These all were either associated with cached error messages or fusion logs (like the one I showed in the original question), as well as a backup of the registry that I made prior to removing all lingering remains of the 9.0.2.7 provider.
Cary Jensen
Looks like you will need to try and debug the MSBuild task that happens in the background. The easiest way to do this open a RAD Studio Command Prompt, navigate to the folder with your project and execute the following commandmsbuild /verboisty:diagnostic > log.outYou will then need to look through log.out to see where it is locating the assembly from.
LanceSc
Thanks for this suggestion. I am neck deep in a different project right now and will do this once I come up for air.BTW, I can copy all of the project files to another VM that never had the 9.0.2.7 file installed, and everything works fine. So, there appears that this is not a matter of something hanging around in the project files.
Cary Jensen
The installation that exhibited this behavior is in a VM that is no longer functioning. Another developer I know experienced this same problem. The solution was to abandon the installation. I feel that something in the installer of the particular version of this .NET data provider left some strange artifact that produced the problem. It does not happen with any other build of this data provider. I am no longer pursuing an answer to this question.
Cary Jensen
Spoke too soon. A colleague of mine, today, encountered this same error, with a slightly earlier version of this same .NET data provider (9.0.2.1). He is now in the same position I was. He cannot run his application with any version of the data provider, save the old one. That assembly was being used as a local copy, and the old version is not in the gac. Using his machine, we ran the run MSBuild with the verbose option. The build worked fine with no errors. Nonetheless, the compile application failed to run, having failed to find the old version of the provider.
Cary Jensen