需要支持(小)项目,几个问题,并获得更多...... [英] Need support for a (small) project, several questions and getting more...

查看:55
本文介绍了需要支持(小)项目,几个问题,并获得更多......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我刚刚开始使用C#,所以我不太了解。



我我为我制作的信息文件创建了一个NFO查看器。



想法如下:

- 自定义皮肤(因此没有默认的窗口边框)和自己的按钮;

- 一个richtextbox,可转换并显示.nfo文件,自动滚动和循环;

- 应用程序启动时的音乐,暂停音乐的按钮(声音关闭);

- 作为网站按钮的图片;

- 自定义图标;

- 我想将它作为一个独立的可执行文件使用,它可以直接运行而且不必查找它需要的文件(音乐文件和nfo,dll'等等)

为此你应该以某种方式使用资源功能。



此时的情况

我现在有一个运行的应用程序,自定义皮肤/按钮,循​​环音乐(.it文件),

循环autoscrollin g文本,用户无法与框交互:我不希望他们选择等,没有自定义图标。 (.NFO)文本和.it音乐从默认位置(C:\ Test \ xx.nfo等)加载。

它是使用Visual Studio 2010制作的。我将它设置为x86,因为x64甚至不能在我的笔记本电脑上以调试模式工作。我使用Windows 7旗舰版x64。

我想我的应用程序不能在XP上工作,因为我使用/参考.NET 4,但我希望它至少在W7变种上运行。



问题此时:

1)看来我是少数几个能够运行这个应用程序。

它成功了W7 64位.NET 4.0,W7 32位.NET?,W8 64位.NET 4.5。

我正在尝试找到错误的原因或根本无法运行。

当我导出文件并尝试在其他Pc上运行它们时,没有任何反应或者我收到错误。 NET 4不在PC上。但是当我安装.NET 4时,它会像其他人一样保持沉默。

任何人都可以支持我吗?如果你需要项目,源代码,任何文件,请告诉我!

2)我想合并我的应用程序在项目中需要的文件。

我'我已经阅读了很多关于使用Resources的内容,但是根本无法使用它。

大部分时间都是因为代码中没有引用不同的东西当你错过了''使用xxxx''时你就有了。

如果有人有使用资源的经验并在项目中调用它们,请帮帮我。



如果有些人想要预留一些时间来帮助我,而不是有一个想法的不同的人...那么我可以建立在1的想法,知道什么是已经尝试过我的应用程序如何工作。

希望得到一些帮助,等待回复并感谢那些尝试的人! :)

Hello,
I''ve just started working with C#, so I don''t have much knowledge.

I''m creating a NFO viewer for information files I make.

The idea is as following:
- A custom skin (so no default windows border) and own buttons on it;
- A richtextbox that converts and shows the .nfo file, autoscrolling and looping;
- Music on application start, button to pause the music (sound off);
- A picture as button to a website;
- Custom Icon;
- I would like to use it as a standalone executable, which runs directly and doesn''t have to look for the files it needs (the music file and nfo, dll''s? etc.)
For this you should use the resources functionality somehow.

The situation at this point:
I now have an application that runs, custom skin/button, looping music (.it file),
looped autoscrolling text, users can''t interact with the box: I don''t want them to select etc, NO custom icon. The (.NFO) text and .it music are loaded from a default location (C:\Test\xx.nfo etc.).
It''s made using Visual Studio 2010. I set it for x86, as x64 didn''t even work in debug mode on my laptop. I use Windows 7 Ultimate x64.
I guess my application won''t work on XP because I use/refer to .NET 4, but I want it to run at least on the W7 variants.

Problems at this time:
1) It seems I''m one of the few that are able to run this application.
It succeeded on W7 64 bits .NET 4.0, W7 32 bits .NET?, W8 64 bits .NET 4.5.
I''m trying to find the cause of the error or not being able to run at all.
When I export the files and try to run them on other Pc''s, nothing happens or I get an error that .NET 4 isn''t on the Pc. But when I install .NET 4, it keeps silent like the rest.
Can anyone support me with this? If you need the project, sourcecode, any files, just let me know!
2) I want to merge the files my application needs in the project itself.
I''ve read a lot about using Resources, but couldn''t get it to work at all.
Most of the time it''s because there''s no referrence for different things in the code, which you have when you miss the ''using xxxx'' that''s needed.
If anyone has experience with using resources and calling them within the project, help me out.

If some people want to reserve some time to help me out, instead of different people with 1 idea... Then I can build on the ideas from 1, that knows what has been tried already and how my application works.
Hope to get some help, waiting for responses and thanks for those who try! :)

推荐答案

.NET 4将在XP上运行(只要它被修补到SP3 - 它应该是任何情况下)。



最简单的方法(并希望解决您的问题)是为您的应用程序创建一个安装和部署项目,并使用它在新机器上安装您的应用程序 - 它知道什么版本的您需要.NET,并在需要时自动安装它。它还会添加和注册您正在使用的任何DLL文件,如果需要,您可以包含您的数据文件。



我猜测(并且考虑到缺少您提供的信息,即我在此阶段可以做的所有事情,您使用的是新机器上没有的DLL文件,安装程序应该为您解决这个问题。
.NET 4 will work on XP (provided it is patched to SP3 - it should be in any case).

The simplest way to do this (and hopefully fix your problem) is to create a Setup and Deployment project for you application, and use that to install you app on the new machine - it knows what version of .NET you need, and will automatically install it if needed. It will also add and register any DLL files you are using, and you can include your data files if you need to.

I am guessing (and given the lack of info you have provided, that''s about all I can do at this stage) that you have used DLL files that are not present on the new machines, and a setup program should cure that for you.




使用安装部署模块(installshield)或只是使用clickonce!



的资源:

方法#1:

将您的文件添加到项目中。在您的文件上,打开属性,并将buildaction设置为content并复制到输出目录为不要复制

添加资源文件(.resx)并添加您的文件到它。



代码:

file => picture.png

资源文件=> Resource_Manager.resx



Hi,
use the setup deployment module (installshield) or simply use clickonce!

for the resources:
Method #1:
add your file to your project. on your file, open properties, and set "buildaction" to "content" and "copy to output directory" to "do not copy"
Add a "resources file" (.resx) and add your files to it.

in your code :
file => picture.png
resources file => Resource_Manager.resx

var pict = Resource_Manager.picture; // return a bitmap in my case





方法#2:

将您的文件添加到您的项目中。在您的文件上,打开属性,并将buildaction设置为embedded resource并复制到输出目录以复制如果更新



在您的代码中:



Method #2:
add your file to your project. on your file, open properties, and set "buildaction" to "embedded resource" and "copy to output directory" to "copy if newer"

in your code:

string path;
// if the file is at the root of your project, the path will be : var path = "mynamespace.document.docx"
// if it is in a directory named "resources_directory", the path will be : var path = "mynamespace.resources_directory.document.docx"
using (var stream = assembly.GetManifestResourceStream("path"))
{
     // do whatever you want with it
}





如果是一个,文件将在dll中,在案例2中,文件将站在dll旁边。



希望它有所帮助。



in case one, files will be in the dll, and in case 2, files will stand next to the dlls.

hope it helps.


对于C#项目中的资源访问,你可以打开项目公关操作,选择左侧的资源。



第一次,编辑器将允许通过单击此编辑器页面中的链接添加资源文件(这文件将命名为Resources.resx,并将位于属性子文件夹中。

然后你将有一个编辑器,你可以在其中添加文件,字符串,图像,...



要访问程序中的其中一个资源,您只需要通过以下方式引用它:

For Resources access in your C# project, you can open the project properties, select "Resources" on the left.

The first time, the editor will allow to add a resource file by clicking on a link in this editor page (this file will be named "Resources.resx" and will be in the "Properties" subfolder).
Then you will have an editor in which you can add files, strings, images, ...

To access one of those resources in your program, you just have to reference it by something like this :
Image myImageInResource = Properties.Resources.MyImage;
string myStringInResource = Properties.Resources.MyString1;
...





此文件中资源的全名将为:

NamespaceOfYourProject.Properties.Resources.ResourceName

通常,NamespaceOfYourProject在代码中默认使用,你可以省略它。



< b>讨论之后以及使用IrrKlang库资源的具体问题

我成功尝试了这段代码:



The full name of a resource in this file will be :
NamespaceOfYourProject.Properties.Resources.ResourceName
usually, NamespaceOfYourProject is used by default everywhere in your code, and you can ommit it.

After Discussion and your specific problem of using resource with the IrrKlang library
I successfully tried this code:

// First of All create the Sound Engine from IrrKlang library
IrrKlang.ISoundEngine engine = new IrrKlang.ISoundEngine();
// Create a sound source from a file in resource with a name and file extension
IrrKlang.ISoundSource source = engine.AddSoundSourceFromMemory(Properties.Resources.test, "test.mp3");
// Play the sound using the source object reference
engine.Play2D(source,false,false,false);
// Wait 5s
System.Threading.Thread.Sleep(5000);
// Stop the Sound
engine.StopAllSounds();
// Restart the Sound using its name
engine.Play2D("test.mp3");
// Wait 5s
System.Threading.Thread.Sleep(5000);
// Stop the Sound
engine.StopAllSounds();



在这个简短的例子中,你可以看到两种启动声音的方法。

但是你必须提供一个带有原始文件扩展名的名字(在我的例子中) .mp3)

我试过没有它,没有声音(也没有错误)播放。

我认为这是IrrKlang库的限制,你可能会报告这可能是一个错误或可能的改进。我个人认为如果引擎在无法识别声源时报告错误将会很好。

播放声音时,play2D方法总是返回一个ISound对象。


In this short example, you can see 2 ways to start the sound.
But you must provide a name with its original file extension (in my case ".mp3")
I tried without it, and no sound (nor error) was played.
I think it is a limitation of this IrrKlang library, you might report this as a bug or a possible amelioration to do. I personnaly think it will be nice if the engine report an error when it did not recognise the sound source.
The play2D method always returns an ISound object if playing a sound OR NOT.


这篇关于需要支持(小)项目,几个问题,并获得更多......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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