0

Library Project compiles fine for ANY CPU in VS2008 running on Win 7 64 -bit.

Now in the post build following command fails when attemptiong to register library dll:

PS C:\Windows\Microsoft.NET\Framework64\v2.0.50727> .\installutil C:\path\Project.dll

Exception occurred while initializing the installation:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\path\Project.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format..

Do I need to compile the project as x64 I was under impression that AnyCPU will take care of it.

Alo my library does have dependencies. Do they also need to be compiled as x64 bit?

Any help is appreciated.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Boris Kleynbok
  • 317
  • 2
  • 5
  • 15

1 Answers1

0

On Windows 7 64 bit Powershell runs as 32 bit application and 64 bit application.

In the Snap-in project one must reference a 32-bit System.Management.Automation library which is located in C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll if Snap-in is compiled to run under Powershell(x86) which is 32-bit.

Default library however is 64-bit and located in C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll

One cannot register 64-bit Powershell snap-in compiled library via C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil which is 32 -bit

and will get exceptions from installation utility and installation will be rolled-back.

Boris Kleynbok
  • 317
  • 2
  • 5
  • 15