l33t
l33t

Reputation: 19956

WPF Performance Suite throws BadImageFormatException

I need to profile my WPF 4.0 application. When I try to open it in WPF Performance Suite 4.0 (from Windows SDK 7.1) it throws a BadImageFormatException:

enter image description here

It complains about a newer runtime, so I ran corflags on my exe to check the runtime version. It says:

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 1
ILONLY    : 1
32BIT     : 0
Signed    : 0

What's wrong? Why can't I open this WPF application in the profiler?

UPDATE

Tried JeffRSon's suggestion which produced another exception:

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.WpfPerformance.ToolAssembly..ctor(Assembly assembly)
   at Microsoft.WpfPerformance.Controls.AddToolDialog.ScanAssembly(String filename)
   at Microsoft.WpfPerformance.Controls.AddToolDialog.ScanAssembly()

Upvotes: 1

Views: 365

Answers (1)

JeffRSon
JeffRSon

Reputation: 11186

Create a file called WpfPerf_managed.exe.config in C:\Program Files\Microsoft Windows Performance Toolkit\WPF Performance Suite or wherever WPF Performance Suite is installed with the following content:

<?xml version="1.0"?>
<configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
   </startup>
</configuration>

This enables side-by-side runtimes in one process.

Restart WPF Performance Suite and load your assembly.

Upvotes: 3

Related Questions