VS2005 换了win7系统 项目运行异常

bf3400 2010-02-01 06:10:05
未处理 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上没问题...
...全文
516 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cyloofts 2012-08-07
  • 打赏
  • 举报
回复
怎么解决的啊?请大侠帮忙,我也遇到同样的问题了。。。 [Quote=引用 5 楼 的回复:]
解决了...
[/Quote]
bf3400 2010-02-02
  • 打赏
  • 举报
回复
解决了...
yijianxiangde100 2010-02-02
  • 打赏
  • 举报
回复
还真没有见过。
JavaK 2010-02-01
  • 打赏
  • 举报
回复
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,这个我没试过。我想应该可行
readfuture 2010-02-01
  • 打赏
  • 举报
回复
友情帮顶。
wgx8057 2010-02-01
  • 打赏
  • 举报
回复
专业性非常强的,因为基本上没有太多这方面的开发,还是再重新检查一次或多次,也能发现其中的奥妙啊!俺有这个体会,请尝试一下!

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧