C# 应用程序无法在另一台计算机上运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2307437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# application doesn't run on another computer
提问by Sergey
I complied my C# windows forms application on Visual Studio 2008 with configuration "Release". When I try to run it on another computer, no windows are shown at all. Complied on Windows 7, another computer has windows xp installed. What can it be?
我在 Visual Studio 2008 上使用配置“Release”编译了我的 C# windows 窗体应用程序。当我尝试在另一台计算机上运行它时,根本没有显示任何窗口。在 Windows 7 上编译,另一台计算机安装了 windows xp。它可以是什么?
Added: I didn't create any installer. Another machine has .net framework 3.0, not 3.5 installed, but simple hello world application works just fine. I tried to copy the program to another folder on my computer - no changes.
补充:我没有创建任何安装程序。另一台机器有 .net framework 3.0,没有安装 3.5,但简单的 hello world 应用程序工作正常。我试图将程序复制到我电脑上的另一个文件夹 - 没有任何变化。
采纳答案by t0mm13b
Double check on the .NET version, if you built a release against .NET 3.5, and the other machine does not have .NET 3.5, that must be installed I'm afraid, not alone that, don't forget the Service Pack 1 as well. Have a look at this SO threadhere to determine the .NET version that is installed, run it on the computer that 'appears to be broken' to see what version...
仔细检查 .NET 版本,如果您针对 .NET 3.5 构建了一个版本,而另一台机器没有 .NET 3.5,则必须安装 恐怕不是唯一的,不要忘记 Service Pack 1以及。在这里查看此 SO线程以确定安装的 .NET 版本,在“似乎已损坏”的计算机上运行它以查看哪个版本...
回答by David Bo?jak
There are a lot of possibilities, from permission problems to difference in installed framework versions. Consider adding a deployment project, at least then all your dependencies will be taken care of, removing a large set of possible issues.
有很多可能性,从权限问题到已安装框架版本的差异。考虑添加一个部署项目,至少这样你的所有依赖都会得到处理,消除大量可能的问题。
Edit: We won't really be able to help without more details though.
编辑:如果没有更多细节,我们将无法真正提供帮助。
回答by Otávio Décio
Create a setup program instead of simply copying the files. This will help determine if you are missing anything such as .net fw 3.5.
创建安装程序而不是简单地复制文件。这将有助于确定您是否缺少任何内容,例如 .net fw 3.5。
回答by Otávio Décio
I agree with everyone. There are a lot of things that could go wrong. Here is my take on this issue. Are you spawning any threads when application starts up? If so, make sure you child threads are not failing and if you're doing any exception handling, keep in mind that you will not be able to catch exceptions in child threads from the main thread as they don't bubble up and will essentially be swallowed. Just a heads up.
我同意大家的看法。有很多事情可能会出错。这是我对这个问题的看法。应用程序启动时是否产生任何线程?如果是这样,请确保您的子线程没有失败,并且如果您正在执行任何异常处理,请记住,您将无法从主线程捕获子线程中的异常,因为它们不会冒泡并且本质上将被吞下。只是抬头。
回答by CodingWithSpike
Try running your program from a command prompt. Sometimes a message will be dumped to the console. I'm going to guess that it has to do with the .net version though.
尝试从命令提示符运行您的程序。有时消息会被转储到控制台。不过,我猜这与 .net 版本有关。
回答by Sameh Deabes
You said:
你说:
Another machine has .net framework 3.0, not 3.5 installed
另一台机器安装了 .net framework 3.0,而不是 3.5
If you configured your project to run with .NET 3.5 then you MUSTinstall it on the other machine.
如果您将项目配置为使用 .NET 3.5 运行,那么您必须将其安装在另一台机器上。
回答by user1061964
Simply add another form in your solution explorer and copy your source code from previous form to the new form and also from form designer to new form designer.
只需在解决方案资源管理器中添加另一个表单,然后将源代码从以前的表单复制到新表单,并从表单设计器复制到新表单设计器。
回答by Patrick
Start your program and afterwards take a look in windows Event log. You will find an error entry in windows protocols application. There are maybe two entries. It tells you the reason.
启动您的程序,然后查看 Windows 事件日志。您将在 windows 协议应用程序中找到错误条目。可能有两个条目。它告诉你原因。
回答by Nickolay Kutovoy
Run your app in a console, prefixing with dotnet:
在控制台中运行您的应用程序,以 dotnet 为前缀:
dotnet yourapp.exe
it gave me more logs to deal with.
它给了我更多的日志来处理。