简体   繁体   English

C# Windows 表单应用程序未处理异常

[英]C# Windows Form Application Unhandled Exception

I created a WFA for my friend's birthday, made a setup and sent the app to my friend.我为朋友的生日创建了一个 WFA,进行了设置并将应用程序发送给了我的朋友。 In the back end of the code I had to manually change the background wallpaper of the program on a button click and I used this.BackgroundImage = new Bitmap(@C:\Users\Admin\Desktop\Birthday_candles.jpg");在代码的后端,我必须通过单击按钮手动更改程序的背景墙纸,我使用了 this.BackgroundImage = new Bitmap(@C:\Users\Admin\Desktop\Birthday_candles.jpg");

I did the same thing with System.Media.Player.SoundPlayer player = new System.Media.SoundPlayer();我对System.Media.Player.SoundPlayer player = new System.Media.SoundPlayer();做了同样的事情player.SoundLocation = @"C\Users\Admin\Downloads\Happy.wav"; player.SoundLocation = @"C\Users\Admin\Downloads\Happy.wav";

How do I add them on my setup file or something like this because if I delete, change location of those two components I get a "Unhandled exception has occured in your application. If you click Continue, the app will ignore this error and attempt to continue. If you click Quit, the app will close immediately."如何将它们添加到我的设置文件或类似内容中,因为如果我删除,更改这两个组件的位置,我会收到“您的应用程序中发生未处理的异常。如果单击继续,应用程序将忽略此错误并尝试继续。如果您单击退出,应用程序将立即关闭。”

Is there any solution with the code, setup or anything so it saves the files and keeps them even if the files are deleted or their address is changed.是否有任何代码、设置或任何解决方案,因此即使文件被删除或地址被更改,它也会保存文件并保留它们。

Thank you!谢谢!

You can embed the resources on the Properties > Resources.resx.您可以在 Properties > Resources.resx 上嵌入资源。 Accessing the image would look like as follows:访问图像如下所示:

PanelName.Image = Properties.Resources.ImageName;

You can add the code snippet on a button click event.您可以在按钮单击事件上添加代码片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#-Windows窗体-如何从任务中捕获未处理的异常 - C# - windows form - how to catch an unhandled exception from a task C#Windows窗体FormatException未处理 - C# Windows Form FormatException was unhandled C#中未处理的异常 - Unhandled Exception in c# 在C#(Windows窗体应用程序)中使用控制台窗口时发生异常 - Exception when using console window in C# (Windows form application) C#控制台应用程序-在找到可用和可用的Ram空间时出现未处理的异常。在Windows窗体应用程序中获取确切答案 - C# console application - Unhandled exception while finding the Available and free Ram space.Getting exact answer in windows forms application Windows Service应用程序中未处理的异常 - unhandled exception in windows service application C# 如何调查:应用程序引发了未处理的异常 - C# How to investigate: An unhandled exception was thrown by the application 空引用异常未处理的C#控制台应用程序 - Null Reference Exception was unhandled C# console application C#应用程序中未处理的异常会导致应用程序崩溃吗? - Unhandled exception in C# application does it crash the app? C# 控制台应用程序中未处理的异常导致 AppCrash - Unhandled Exception in C# Console Application causing AppCrash
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM