在 Windows 7 64 位机器上为 Windows 7 32 位平台构建 C# [英] Building C# for Windows 7 32 bit platform on Windows 7 64 bit machine

查看:28
本文介绍了在 Windows 7 64 位机器上为 Windows 7 32 位平台构建 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 7 64 位计算机上使用 Visual Studio 2010 为 Windows 窗体应用程序构建安装程序以在 Windows 7 32 位计算机上安装和运行的正确方法是什么?

Whats the correct way to build the setup installers for a Windows Forms app to install and run on a Windows 7 32 bit machine, using Visual Studio 2010 on a Windows 7 64 bit machine ?

我刚刚清理了一个使用 SQL Express 2005 的 3 年旧的 Visual Studio 2008 应用程序,该应用程序基于 Windows XP 构建.

I've just brushed the dust off a 3yr old Visual Studio 2008 app, built on Windows XP, using SQL Express 2005.

我已将其更新为 VS2010、SQL Express 2008,并在 Windows 7 64 位机器上重建.它需要在 Windows 7 32 位平台上运行.

I've updated it to VS2010, SQL Express 2008, and rebuilt it on a Windows 7 64 bit machine. It needs to run on a Windows 7 32 bit platform.

数据库的安装项目在运行时一直失败(在启动时),说它仅适用于 x64 机器.(应用程序的设置运行正常并安装.)

The setup project for database keeps failing (on startup) when run, saying its only for an x64 machine. (The setup for the app runs ok and installs.)

我已经完成了解决方案中的每个项目,并将其设置为使用 x86(而不是任何 CPU)构建.我已经删除了所有先决条件.唯一值得怀疑的是 DB CustomAction 项目(运行 db 脚本).

I've been through every project in the solution and set it to build using x86 (as opposed to Any CPU). I've removed all PreRequisites. The only thing suspect left in there is a DB CustomAction project (which runs the db scripts).

从谷歌搜索来看,在我看来,它是在带有任何 CPU"的 64 位机器上构建的,这意味着它应该生成可通过 WOW 在 32 位机器上运行的安装文件?并且无需进行我一直在进行的所有更改?我是否遗漏了一些非常明显的东西?

From googling it seems to me building on a 64 bit machine with 'Any CPU', means it should produce setup files that will run on a 32 bit machine via WOW ? and without having to make all the changes Ive been making ? Am I missing something bleedingly obvious ?

谢谢.

推荐答案

我总是觉得遇到与我从未发布过解决方案的相同问题的帖子令人沮丧.因此,我将发布我发现的内容,以防有朝一日对其他人有用.我发现很多其他开发人员报告漫无目的的 Windows 7 程序已停止工作"的消息.

I always find it frustrating coming across posts of the same question I have that never had a resolution posted. So I'll post what I found in case it, or even some if it, is of use to others one day. I found a lot of other developers reporting the aimless Windows 7 program 'has stopped working' message.

顺便说一下,我发现测试部署应用程序和安装程序的最简单方法是构建一个虚拟 PC 机器,其配置与平台最终运行的配置相同.然后复制那个 Virtual PC,并在副本上测试运行.这样,我可以随时删除副本,从原件重新复制并快速重新开始.

By the way, I found the easiest way to test deploying the app and the installers was to build a Virtual PC machine with the same configuration as the platform will eventually run on. Then copy that Virtual PC, and test run on the copy. That way, I can just delete the copy at any time, recopy from the original and start over, quickly.

是的,正如 Cosmin 所说,解决方案的 TargetPlatform 属性也需要设置为 x86.无论如何,没有解决问题,应用程序仍然产生已停止工作"消息.

Yes, as Cosmin said, the TargetPlatform Property of the solution also needs setting to x86. Anyway, didnt fix the the problem, the app still produced the 'has stopped working' message.

接下来我检查了 SQL 日志 ERRORLOG 文件 (c:Program FilesMicrosoft SQL ServerMSSQL10.SQLExpressMSSQLLog),它报告应用程序试图使用混合模式身份验证登录,而 SQL 设置为Windows 身份验证.现在我知道我在安装 SQL Express 时选择了混合模式,因为我的应用程序使用了一个 sql 服务帐户,我的数据库安装程序为其创建了该帐户.所以不知何故被某些东西改变了(不知道是什么?).要通过 SQL Server Management Studio 设置为混合模式,您只需右键单击实例,选择安全,然后更改服务器身份验证.如果没有Management Studio,则需要编辑注册表HKEY_LOCAL_MACHINE/Software/Microsoft/Microsoft SQL Server//MSSQLServer,并为Mixed编辑键LoginMode = 2.再次,没有解决问题,应用程序仍然产生已停止工作"消息.

Next I checked the SQL logs ERRORLOG file (c:Program FilesMicrosoft SQL ServerMSSQL10.SQLExpressMSSQLLog) and it was reporting the app was trying to logon using Mixed Mode authentication, whereas SQL was set for Windows Authenication. Now I KNOW I selected Mixed mode when I installed SQL Express, as my app uses a sql service account which my db installer creates the account for. So somehow that was changed by something (dont know what?). To set to Mixed mode via SQL Server Management Studio you just right click on the instance, select Security, and change Server Authentication. Without Management Studio, you need to edit the registry HKEY_LOCAL_MACHINE/Software/Microsoft/Microsoft SQL Server//MSSQLServer, and edit key LoginMode = 2 for Mixed. Once again, didnt fix the problem, the app still produced the 'has stopped working' message.

接下来,我偶然发现了一些关于此消息的帖子,可能是在启动过程中通过在 Windows 7 上加载 32 位应用程序引起的.我将 MessageBoxes 和 Try/Catchs 放在我可以的第一行,但它们从未显示过,并且没有发现错误.

Next, by chance I stumbled across some posts about this message can be caused during startup by loading 32 bit apps on Windows 7. I put MessageBoxes, and Try/Catchs on the first lines I could, and they never got displayed, and no error was caught.

我接下来尝试的是在我的 exe 上运行 DependencyWalker.它报告了 2 x 32 位文件丢失:IEShims.dll 和 GPSVC.dll.有其他开发人员的帖子遇到了这个问题,最终结果是我在 C:Windowswinsxs 中找到了它们(GPSVC.dll 被称为 x86_microsoft-windows-g..licy-base.resources_31bf3856ad364e35_6.1.7600.16385_en-us_c19ps2af2.mui_0c160ac2).我把它们放到 C:WindowsSystem32 中,重新编译我的应用程序,将它部署到我的测试机器上,它终于运行了!

The next thing I tried was to run DependencyWalker over my exe. It reported 2 x 32 bit files missing: IEShims.dll and GPSVC.dll. There are posts from other devs encountering this, and the end result was I found them in C:Windowswinsxs (GPSVC.dll was called x86_microsoft-windows-g..licy-base.resources_31bf3856ad364e35_6.1.7600.16385_en-us_c10af1bed239c523_gpsvc.dll.mui_0c160ac2). I dropped them into C:WindowsSystem32, recompiled my app, deployed it to my test machine, and it finally ran !

仍然不明白为什么只是将它们放入我的开发箱上的 System32 目录中就可以使应用程序在测试机器上运行?但无论如何,它解决了问题,希望这对其他人有所帮助.

Still dont understand why just putting them into the System32 dir on my dev box made the app run on the test machine ? But anyway, it fixed the problem, and hope this is of help to others.

这篇关于在 Windows 7 64 位机器上为 Windows 7 32 位平台构建 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆