未处理 System.BadImageFormatException
  Message="试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)"
  Source="Kennedy.ManagedHooks"
  StackTrace:
       在 Kennedy.ManagedHooks.SystemHook.SetUserHookCallback(HookProcessedHandler hookCallback, HookTypes hookType)
       在 Kennedy.ManagedHooks.SystemHook..ctor(HookTypes type) 位置 E:\C#毕业项目\浪潮卡拉ok点歌系统\SystemHooks\ManagedHooks\SystemHook.cs:行号 44
       在 Kennedy.ManagedHooks.KeyboardHook..ctor() 位置 E:\C#毕业项目\浪潮卡拉ok点歌系统\SystemHooks\ManagedHooks\KeyboardHook.cs:行号 39
       在 浪潮卡拉ok点歌系统.MainForm..ctor() 位置 D:\C#毕业项目\浪潮卡拉ok点歌系统\浪潮卡拉ok点歌系统\MainForm.cs:行号 121
       在 浪潮卡拉ok点歌系统.LoginForm.picDengLu_Click(Object sender, EventArgs e) 位置 D:\C#毕业项目\浪潮卡拉ok点歌系统\浪潮卡拉ok点歌系统\LoginForm.cs:行号 151
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 浪潮卡拉ok点歌系统.Program.Main() 位置 D:\C#毕业项目\浪潮卡拉ok点歌系统\浪潮卡拉ok点歌系统\Program.cs:行号 18
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
---------------------------------------------------------
/// <include file='ManagedHooks.xml' path='Docs/SystemHook/ctor/*'/>
public SystemHook(HookTypes type)
{
_type = type; _processHandler = new HookProcessedHandler(InternalHookCallback);
SetCallBackResults result = SetUserHookCallback(_processHandler, _type);//异常
if (result != SetCallBackResults.Success)
{
this.Dispose();
GenerateCallBackException(type, result);
}
}未处理BadimageFormatException
试图加载格式不正确的程序.(异常来自HRESULT:0x8007000B)弄了个全局截取按键的 在xp上没问题...

解决方案 »

  1.   

    solution1:
    因为win7是64位的,System.Data.CTP.dll and System.Data.Entity.dll这两个dll是引用的系统的(MS上说这两个是混合形的,也就是说它可以在32位-x86上运行也可以在64位上运行,win7中默认是64),那么你可以在Win7中装个vs看看你这里的代码改一种方式写应该可以。如:
    public static bool IsWindowsXP()
            {
                System.OperatingSystem os = System.Environment.OSVersion;
                if (os.Platform == System.PlatformID.Win32NT && os.Version.Major == 5 && os.Version.Minor == 1)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }solution2:因为 System.Data.CTP.dll and System.Data.Entity.dll这两个dll是引用的系统的(MS上说这两个是混合形的,也就是说它可以在32位-x86上运行也可以在64位上运行,win7中默认是64, XP,Vista有32位和64位的),但是可以强制这些DLL以什么方式运行,在VS Project的的Build选项中的 "platform target",选择x86,这个我没试过。我想应该可行