Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#应用程序不';I don’我的电脑和我的差不多_C#_Windows_Compatibility_Requirements - Fatal编程技术网

C#应用程序不';I don’我的电脑和我的差不多

C#应用程序不';I don’我的电脑和我的差不多,c#,windows,compatibility,requirements,C#,Windows,Compatibility,Requirements,不幸的是,我还没有在搜索区或任何其他编码论坛中找到我要找的awnser,所以我将把我的问题留在这里,等待结束 我开发了一个非常简单的C#应用程序,Windows的一个启动项目——迷宫应用程序,它使用一个带有标签的简单面板和简单的鼠标事件来触发指针位置的重新放置 我已经成功地发布了我的应用程序,它可以在我的电脑和其他一些电脑上顺利运行,但由于一些奇怪的原因,它根本无法加载到我朋友的笔记本电脑上 我们都共享相同的操作系统(Windows 7),我们都有x64版本,而且框架似乎是相同的,但即使进程显示

不幸的是,我还没有在搜索区或任何其他编码论坛中找到我要找的awnser,所以我将把我的问题留在这里,等待结束

我开发了一个非常简单的C#应用程序,Windows的一个启动项目——迷宫应用程序,它使用一个带有标签的简单面板和简单的鼠标事件来触发指针位置的重新放置

我已经成功地发布了我的应用程序,它可以在我的电脑和其他一些电脑上顺利运行,但由于一些奇怪的原因,它根本无法加载到我朋友的笔记本电脑上

我们都共享相同的操作系统(Windows 7),我们都有x64版本,而且框架似乎是相同的,但即使进程显示在任务管理器中,它也不会加载,即使安装成功

因此,程序确实在运行,但似乎不会加载,也不会抛出任何异常或错误进行分析

因此,我的问题是,我的程序与其他计算机完全兼容的要求是什么

我感谢大家的关注,我花了很多时间在这件事上,但似乎找不到正确的awnser

我还将显示我的表单代码以供进一步分析:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace Labirinto
    {
        public partial class frmLabirinto : Form
        {
            // Toca um som sempre que o utilizador bater numa parede
            System.Media.SoundPlayer startSoundPlayer = new System.Media.SoundPlayer(@"C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\doh.wav");
            // Toca um som sempre que o utilizador chegar ao final do labirinto
            System.Media.SoundPlayer finishSoundPlayer = new System.Media.SoundPlayer(@"C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\tada.wav");


    public frmLabirinto()
    {
        InitializeComponent();
        MoveToStart();
    }

    private void frmLabirinto_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// O método permite que o ponteiro do rato volte ao ponto inicial
    /// </summary>
    private void MoveToStart()
    {
        startSoundPlayer.Play(); //Toca o som de reinicio do jogo
        Point startingPoint = panel1.Location; //ponto inicial
        startingPoint.Offset(10, 10); //localizacao do ponto inicial
        Cursor.Position = PointToScreen(startingPoint); //coloca o cursor no local inicial
    }

    private void finishLabel_MouseEnter(object sender, EventArgs e)
    {
        finishSoundPlayer.Play(); //Toca o som de fim de jogo
        // Congratula o utilizador através de uma mensagem no ecrã
        MessageBox.Show("Parabéns, encontrou a saída do labirinto");
        Close();
    }

    private void wall_MouseEnter(object sender, EventArgs e)
    {
        MoveToStart(); //recoloca o ponteiro no ponto inicial ao embater numa parede
    }


}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Windows.Forms;
名称空间标签
{
公共部分类frmLabirinto:表单
{
//这是一个非常有用的方法
System.Media.SoundPlayer startSoundPlayer=new System.Media.SoundPlayer(@“C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\doh.wav”);
//这是最后一次拉比林托的比赛
System.Media.SoundPlayer finishSoundPlayer=new System.Media.SoundPlayer(@“C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\tada.wav”);
公共frmLabirinto()
{
初始化组件();
MoveToStart();
}
私有void frmLabirinto_加载(对象发送方,事件参数e)
{
}
/// 
///您可以在您的私人住宅中使用您的私人住宅
/// 
私有void MoveToStart()
{
startSoundPlayer.Play();//Toca o som de reincio do jogo
Point startingPoint=panel1.位置;//ponto inicial
起始点。偏移量(10,10);//本地
Cursor.Position=PointToScreen(startingPoint);//光标没有本地图标
}
私有void finishLabel_MouseEnter(对象发送方,事件参数e)
{
finishSoundPlayer.Play();//Toca o som de fim de jogo
//恭喜你,这是一个成功的计划
MessageBox.Show(“抛物线,一个拉比兰托的圣母玛利亚”);
Close();
}
私有void wall_MouseEnter(对象发送器,事件参数e)
{
MoveToStart();//请记住,您没有对努马·帕雷德大使馆的任何意见
}
}
}

您是否尝试使用诊断程序集加载错误


如果没有问题,请将日志代码添加到应用程序中,并检查代码中是否存在“吞咽”错误的try/catch块。

我感觉初始化两个SoundPlayer对象时使用的硬编码值导致了错误。例如,如果运行应用程序的机器上没有名为“Ricardo Borges”的用户,该怎么办

System.Media.SoundPlayer startSoundPlayer = new System.Media.SoundPlayer(@"C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\doh.wav"); 
System.Media.SoundPlayer finishSoundPlayer = new System.Media.SoundPlayer(@"C:\Users\Ricardo Borges\Documents\Visual Studio 2010\Projects\Labirinto\Labirinto\Resources\tada.wav");
对于SoundPlayer对象“如果路径或URL无效,SoundPlayer仍将被构造,但随后对加载或播放方法的调用将失败。”

MoveToStart函数中的第一行包含以下行:

startSoundPlayer.Play(); 
返回MSDN以了解该方法,根据错误原因,它可能引发三种不同的异常之一--FileNotFoundException似乎是一个可能的罪魁祸首


您能否确认存在问题的机器上存在指定位置和实际文件?

如何硬编码startSoundPlayer和finishSoundPlayer的值。。确保您的好友系统中存在这些文件。@Parv:+1。我甚至没有检查密码!如果程序被编译成exe,那么这是严格必要的吗?那么,我应该如何以更合适的方式添加引用呢?“如果程序被编译成exe,那么这是非常必要的”——这个评论没有意义。如果路径在计算机上不存在,那么您当然需要对其进行参数化,或者将任何资源编译到您的可执行文件中。您是否检查了受影响计算机上的事件查看器,以查看它是否有基于应用程序故障的条目?否,但实际上让我感到困惑的是,相同的版本在其他计算机上工作过,也不会有相同的路径。但我理解你的所有观点,我感谢你的努力。我如何实际替换该引用,以便在发布/构建该引用时,该引用与项目所需的其余文件一起继续执行?@vuk77您需要向应用程序添加一些日志记录(System.Diagnostics),尤其是在加载和初始化数据的区域。如果您可以捕获错误,那么它将帮助我们缩小原因。