开发者

I can not run a published application on another computer

开发者 https://www.devze.com 2023-02-19 19:42 出处:网络
I have developed a game in Visual Studio C# with XNA. When I publish the application, in 开发者_如何学运维a ClickOnce Application, it works fine on my computer.However, I tried to .zip the folder and

I have developed a game in Visual Studio C# with XNA. When I publish the application, in 开发者_如何学运维a ClickOnce Application, it works fine on my computer. However, I tried to .zip the folder and upload online through ftp and when I download and install on a different computer it does not work. It just says "'Application Name' has Stopped Working". Can anyone help me?


The error message you are getting is because the .NET Framework or XNA Framework of the correct version is not installed.

You could simply install them on the target machine, but presumably you want to get ClickOnce working.

Right click your project and click Properties. First of all go to the Application and make a note of the "Target Framework". Then go to the Publish page and click Prerequisites. Typically you will need:

  • Microsoft .NET Framework 4 Client Profile (x86 and x64)
  • Microsoft XNA Framework Redistributable 4.0
  • Windows Installer 3.1

If you are using other versions of XNA or the .NET Framework, you will need to select the appropriate prerequisites there (or change the version of the framework you are targeting). Windows Installer is required by ClickOnce itself.

Also take note of the checkbox at the very top (it should be checked). It reads "Create setup program to install prerequisite components". What this means is that publish tool will create a setup.exe to go with your project. It is that executable that is responsible for installing the prerequisites (and then launchs your ClickOnce installer). If you install directly with ClickOnce, it may work, but you won't have installed the perquisites, and your game will fail to work (with that obtuse error message) if they are missing.

See also this answer: Feasibility of an XNA game on PC


Sounds like your installer doesn't actually install everything it needs to, and the first computer happens to have the missing dependencies. I'd try fusion logging first, then attach a debugger if you need to.


So my old answer is good information - so I will leave it. But I think it may also be wrong.

I suspect your application is starting fine (frameworks and all), and is then throwing an unhandled exception for some reason. Without knowing what the exception is, I can't really advise you on it. So here's a quick-and-dirty way to find out:

Open up Program.cs and wrap the contents of the function Main it with this:

try
{
    // The old contents of Main go here
}
catch(Exception ex)
{
    MessageBox.Show(ex.ToString());
}

You will also need to add a reference to System.Windows.Forms to your project. I do not recommend leaving this code in place while you are developing (because you want the debugger to stop on unhandled exceptions - and this code is handling them).


Verify that XNA / .NET is correctly installed (down to the specific version)

To find the error, go to the Event Viewer application that comes with windows and look for an error related to the .NET version you have installed. It should show you the specific error.

I can not run a published application on another computer

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号