如何检查代码是否与 Windows 7 兼容
我们正在使用 Visual C# 2008 Express 在 Windows XP 机器(32 位)下开发基于 WPF 的程序。
问题是,我们尝试在两台 Windows 7 机器上运行该程序,一台是 32 位 Windows 7,另一台是 64 位 Windows 7。
在 Windows XP 下一切正常。在 Windows 7 计算机中,它会以 32 位版本启动,但运行一项功能时会出现错误(在 XP 中不会发生这种情况)。
在 W7 64 位中,它甚至无法启动。这是正常的吗?是否不可能在 W7 64 位下运行 32 位程序,即使它们执行速度较慢?
如何检查代码是否与 Windows 7 兼容?
预先非常感谢您。
于伦。
We are developing using Visual C# 2008 Express a program based on WPF under Windows XP machines (32 bits).
The thing is that we have tried to run the program in two Windows 7 machines, one is 32 bits Windows 7 and the other is 64 bits Windows 7.
Under Windows XP everything is fine. In Windows 7 machine, it launches in the 32 bits version altough there is an error when running one functionality (it does not happen in XP).
In W7 64 bits it even does not launch. Is this normal? Is not possible to run 32 bit programs under W7 64-bits,even if they execute slower??
How can we check the code is compatible with Windows 7?
Thank you very much in advance.
Julen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好的,随着用户提供了更多信息,我相信罪魁祸首已经找到了。
客户端在其应用程序中使用 MS Access 数据库(标准 MS Jet 提供商)。问题是 Microsoft 没有 64 位版本的 MS Jet 提供商,并且不会这样做。不知道为什么:)
因此,要使应用程序在 Windows 7 64 位上运行,请执行以下操作:在 Visual Studio 中转到项目属性,然后在“生成”选项卡中,将“平台目标”更改为
Any CPU
代码>x86。这将强制应用程序以仅 32 位模式进行编译(将在 Win7 64 上的 WOW64 下运行),并且应用程序将能够访问 Access 数据库。我相信这就是它没有在 64 位操作系统上运行的原因:)关于“运行一项功能时出现错误”,我建议获取有关该错误的更多详细信息,并用它创建一个新问题。
玩得开心,祝你好运!
Ok, as the user provided some more info, I believe the culprit has been found.
The client uses MS Access database in their app (the standard MS Jet provider). The problem is that Microsoft does not have a 64 bit version of the MS Jet provider, and WILL NOT do it. Don't know why :)
So to make the app run on windows 7 64 bit do this: in Visual Studio go to the project properties, and in the Build tab, Platform target change
Any CPU
tox86
. This will force the app to be compiled in 32bit only mode (will run under WOW64 on Win7 64), and the app will be able to access the Access database. I believe this is why it wasn't running on the 64 bit os :)Regarding the "there is an error when running one functionality", I recommend getting more details about the error, and creating a new question with it.
Have fun, and Good Luck!
我同意 Artiom 的观点,并且只看到一个有效答案:在 Windows 7 上测试它。
我们可以在这里写下可能出现的问题列表(我稍后会做),但您仍然需要
XP 和 Windows 7 之间可能的变化:
用户访问控制(UAC):
这意味着您的程序不会以管理权限运行,除非您
这也意味着您的应用程序无法写入某些文件夹(UAC 尝试“帮助”您进行“虚拟文件夹重定向”:如果您写入 %ProgramFiles%,它会默默地写入您的用户配置文件并“成功”,如果其他用户希望在 %ProgramFiles% 目录中看到您的更改,但它不会。那里),甚至没有出现错误。
关于您的具体报告和问题:
1) 提供有关该功能的更多详细信息。也许它依赖于 Windows7 上不存在的 DLL(但在每台 XP 计算机上都有)。也许这只是与权限有关(见上文)。更多详情->更多帮助。
2)再次,更多细节。可能的候选者:您的应用程序作为 64 位应用程序运行,尽管它通过 P/Invoke 对 32 位本机 DLL 有硬/早期依赖性。再次,您提供的信息不足。
I agree with Artiom and see only one valid answer: Test it on Windows 7.
We could write down a list of possible problems here (and I'll do in a second), but you still need to
Possible changes, between XP and Windows 7:
User Access Control (UAC):
This means that your program doesn't run with administrative rights, unless you
This means also that your application cannot write to some folders (UAC tries to "help" you with "Virtual Folder Redirection": If you write to %ProgramFiles% it silently writes to your user profile and "succeeds". If another user expects to see your change in the %ProgramFiles% directoy though it won't be there), without even getting an error.
Regarding your specific reports and problems:
1) Give more details regarding that functionality. Maybe it depends on a DLL that is not present on Windows7 (but was on every XP machine). Maybe it's just related to permissions (see above). More details -> More help.
2) Again, more details. Possible candidate: Your application runs as 64bit application, although it has hard/early dependencies on 32bit native DLLs via P/Invoke. Again, you provide not enough information.
我认为这不是兼容性的问题。
Windows 7,32 位和 64 位都应该与 C# WPF 应用程序完全兼容。而且它在 64 位操作系统上的运行速度不会明显减慢。您不应该注意到任何性能下降。
如果你的应用程序在 Win7 上崩溃,请检查你的代码,检查它抛出的异常。我几乎确信罪魁祸首就在那里。
I think it's not a question of compatibility.
Windows 7, both 32bit and 64bit should be completely compatible with C# WPF apps. And it won't run visibly slower on the 64bit os.. You shouldn't notice any degradation.
If your app is crashing on Win7 check your code, check the exceptions it's throwing.. I'm almost confident the culprit is there.
当我在 Win XP 32 位中开发一个业余爱好项目并尝试在 64 位 Vista 中运行它时,我也有同样的iseeu。即使目标 cpu 设置为“任何 CPU”,应用程序甚至没有启动并且有时开始抛出错误。
现在我使用 Win 7 机器(64)位进行开发,并将目标 CPU 设置为“任何 CPU”。它在 Vista 和 XP(32 位和 64 位)中运行没有任何问题。
您也可以仅使用“32 位”模式。您的应用程序不会有任何性能问题。
我建议您在Windows 7电脑中打开该应用程序,然后在Vista和xp等较低版本中调试或重新编译并测试它。
I had the same iseeu when I developed an hobby project of mine in Win XP 32 bit and tried running it in 64 bit Vista. The app didnt even start and started throwing error sometimes even though the target cpu was set as "Any CPU".
Now I develop with a Win 7 machine (64) bit and I set the Target CPU as "Any CPU". It ran without any issues in Vista and XP (both 32 bit and 64 bit).
you can also taget only "32 bit" mode. Your app wont have any performance issues.
I would suggest you to open the app in a Windows 7 pc and then debug or recompile and test it in lower versions like Vista and xp.
除了之前的帖子之外:为了帮助您查找应用程序的问题,还有 应用程序兼容性工具包。
In addition to the previous posts: To help you find issues with your application, there's the Application Compatibility Toolkit.