Executable load problem when linking in assemblies from previous CLR versions.
-
Monday, June 01, 2009 8:17 PMI'm getting a problem when trying to re-implement my WF 3.5 project into WF 4.0. I copied over the code, created a new public class WaitForSeriesComplete : CodeActivity and tried running my executable. I got the following error on start up:
An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module.
Additional information: Could not load file or assembly 'WF4.0Test.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I tried looking in the fuslogvw output and saw the following:
*** Assembly Binder Log Entry (6/1/2009 @ 9:54:42 AM) ***
That didn't give me much information so I tried Dependency Walker:
The operation failed.
Bind result: hr = 0x8013101b. No description available.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\WF4.0Test.exe
--- A detailed error log follows.
LOG: EXE explicit bind. File path:D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\WF4.0Test.exe.
Warning: At least one delay-load dependency module was not found.
--------------------------------------------------------------------------------
Starting profile on 6/1/2009 at 1:55:38 PM
Operating System: Microsoft Windows 2003 Server (64-bit), version 5.02.3790 Service Pack 2
Program Executable: d:\downloads\workflow tutorials\wf4.0test\bin\debug\WF4.0TEST.EXE
Program Arguments:
Options Selected:
Simulate ShellExecute by inserting any App Paths directories into the PATH environment variable.
Log DllMain calls for process attach and process detach messages.
Hook the process to gather more detailed dependency information.
Log LoadLibrary function calls.
Log GetProcAddress function calls.
Log debug output messages.
Automatically open and profile child processes.
--------------------------------------------------------------------------------
Started "WF4.0TEST.EXE" (process 0x173C) at address 0x00400000. Cannot hook module.
Second chance exception 0xE0434F4D (Unknown) occurred at address 0x77D4DD50.
Exited "WF4.0TEST.EXE" (process 0x173C) with code 128 (0x80).
I still didn't see much of a clue that would help me determine which assembly was causing the problem. So I thought I would simplify the problem a bit and wrote this to test things out:
namespace Junk
{
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Reflection;
using System.Activities;
using System.Activities.Statements;
class Program
{
static void Main(string[] args)
{
string Path = @"D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug";
foreach (string filename in System.IO.Directory.GetFiles(Path))
{
if(System.IO.Path.GetExtension(filename).StartsWith(".exe") ||
System.IO.Path.GetExtension(filename).StartsWith(".dll"))
{
AssemblyName assemblyName = AssemblyName.GetAssemblyName(filename);
Assembly assembly = Assembly.Load(assemblyName);
}
}
}
}
}
I used this program and got this output:
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\Junk\bin\Debug\Junk.exe', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\ClearCanvas.Common.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\ClearCanvas.Desktop.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\ClearCanvas.Dicom.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\ClearCanvas.ImageViewer.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\Google.ProtocolBuffers.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\ICSharpCode.SharpZipLib.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\log4net.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PowerCollections.dll'
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.AlgorithmService.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.Communication.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.DICOMDataService.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.ExtensionSupport.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.Math.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.Plugin.Communications.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.Proxies.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.SegmentationService.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.SeriesArchive.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.TransferFunctionService.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.Utilities.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.VolumeClassification.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\PI.VolumeService.Client.dll', Symbols loaded.
'Junk.vshost.exe' (Managed (v4.0.20506)): Loaded 'D:\Downloads\Workflow Tutorials\WF4.0Test\bin\Debug\WF4.0Test.exe', Symbols loaded.
So it seems that everything got loaded up just fine in my test harness. It even loaded up the executable that originally said it had a problem loading something. I'm pretty stumped.
So my question is ... what can I do to further troubleshoot this problem? My code worked fine in WF 3.0/3.5 but not when I try to build it in a WF 4.0 application. Any ideas on what might be wrong?
Grant
All Replies
-
Monday, June 01, 2009 9:18 PM
Well I figured it out. Apparently the runtime for .NET 4.0 changed and there was an errant entry in my app.config file which called out the specific version of the runtime:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
So once I removed the override the application started up just fine. BEWARE!!!
REF: http://msdn.microsoft.com/en-us/kb/kb00318785.aspx- Proposed As Answer by Noman Wednesday, April 20, 2011 8:42 PM
- Marked As Answer by Tim Lovell-SmithModerator Wednesday, December 28, 2011 8:37 PM
-
Friday, June 05, 2009 9:40 PMModerator
Hi Masuto,
Did you add the runtime version to your app.config? I only ask as I'm interested in how this problem came about.
Thanks,
Amy- Proposed As Answer by ScottyDoesKnow Thursday, May 20, 2010 5:55 PM
-
Monday, June 08, 2009 7:42 PM
I looked backwards in the source control system and it seems as though it was always there (i.e. some designer or auto-generated code placed it in there). I migrated the old solution to the new 2010 format and it didn't give me any warnings or anything on migration.
Grant- Proposed As Answer by Saurabh Chechi - MSFTModerator Monday, June 08, 2009 8:36 PM
- Marked As Answer by Saurabh Chechi - MSFTModerator Monday, June 08, 2009 11:37 PM
-
Wednesday, June 30, 2010 3:43 AM
Thanks. Solved my problem too. I didn't add that <supportedRuntime version="v2.0.50727"/> manually either.
-
Wednesday, April 20, 2011 8:44 PMI also had the same issue <supportedRuntime was 2.0 something and Project was building with 4.0
Product Life Cycle Development | Get Backlinks | Get Twitter Followers

