本文介绍了应用程序在调试模式下运行良好,但在发布模式下无法完全运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

我基于libvlc库制作音乐播放器.
我使用DLLs libcore和libvlc,以及安装在计算机上的VLC播放器中的插件.
在调试模式下,播放器将按我的要求播放音乐和视频.
但是在发行模式下,我什么都不会玩.为什么会这样?

插件位于项目文件夹下的资源文件夹中,
并且此代码用于获取它们(无论项目文件夹位于何处,因为即时消息将要在CD上交付我的项目):

Hello.

I making a music player based on the libvlc library.
I use the DLLs libcore and libvlc, and the plugins from the VLC player installed on my computer.
In debug mode, the player plays music and video as i should.
But in release mode, i wont play anything. Why is this?

The plugins are located in the resource folder beneath the project folder,
and this code is used to get to them (wherever the project folder is located, because im going to deliver my project on a CD):

String path = (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
path = path.Replace("\\bin\\x86\\Debug", "\\Resources");
path = "--plugin-path=" + path;
instance = new VlcInstance(new String[] { path });



两个DDL(libcore和libvlc)位于此文件夹中:

C:\ Users \ Trond \ Documents \ Hiof \ 6.学期\ dotNET \ VLCMediaPlayer \ VLCMediaPlayer \ bin \ x86 \ Debug

与此有关吗?

最好的问候,Trond:)



And the two DDLs (libcore and libvlc) are located in this folder:

C:\Users\Trond\Documents\Hiof\6. Semester\dotNET\VLCMediaPlayer\VLCMediaPlayer\bin\x86\Debug

Has it something to do with this?

Best regards, Trond :)

推荐答案

string exeLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
string exeDirectory = System.IO.Path.GetDirectoryName(exeLocation);


这种方式非常通用,可以容忍应用程序的托管方式和所有其他详细信息.还有其他方法不够精确.

另一种选择是使用嵌入在可执行文件中的资源,例如* .resx资源.

—SA


This way if very universal, tolerant to the way the application is hosted and all other detail. There are other methods which are not that accurate.

Another alternative is using resources embedded in an executable file, such as *.resx resources.

—SA


这篇关于应用程序在调试模式下运行良好,但在发布模式下无法完全运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 03:06