MVC4应用"无法加载DLL“libmp3lame.32.dll” [英] MVC4 App "Unable to load DLL 'libmp3lame.32.dll'

查看:510
本文介绍了MVC4应用"无法加载DLL“libmp3lame.32.dll”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用NAudio.Lame库在MVC4应用程序,并正在错误:

I am trying to use the NAudio.Lame library in an MVC4 application and am getting the error:

Unable to load DLL 'libmp3lame.32.dll': The specified module could not be found.

我通过添加的NuGet库。我能得到很好地工作与Windows窗体应用程序库,所以我相信这个问题是特定于MVC4。

I added the library via NuGet. I was able to get the library to work fine with a Windows Forms application, so I believe the problem is specific to MVC4.

我试图从图书馆笔者在这里建议:
http://stackoverflow.com/a/20065606/910348

I tried the advice from the library author here: http://stackoverflow.com/a/20065606/910348

推荐答案

这个问题原来是该本机DLL( libmp3lame.32.dll libmp3lame.64.dll )不能被发现,因为Web服务器进程从执行当前目录不是网站的文件夹(其中的DLL所在)和搜索路径不包括文件夹中。

The problem turns out to be that the native DLLs (libmp3lame.32.dll and libmp3lame.64.dll) cannot be found because the current directory that the web server process is executing from is not the website's bin folder (where the DLLs reside) and the search path does not include the bin folder.

您需要做的是添加文件夹复制到 PATH 环境变量,这将使调用LoadLibrary API调用来查找DLL文件。

What you need is to add the bin folder to the PATH environment variable, which will enable the LoadLibrary API call to locate the DLLs.

下面是你可以调用会为你做这个的方法:

Here's a method you can call that will do this for you:

public static void CheckAddBinPath()
{
    // find path to 'bin' folder
    var binPath = Path.Combine(new string[] { AppDomain.CurrentDomain.BaseDirectory, "bin" });
    // get current search path from environment
    var path = Environment.GetEnvironmentVariable("PATH") ?? "";

    // add 'bin' folder to search path if not already present
    if (!path.Split(Path.PathSeparator).Contains(binPath, StringComparer.CurrentCultureIgnoreCase))
    {
        path = string.Join(Path.PathSeparator.ToString(), new string[] { path, binPath });
        Environment.SetEnvironmentVariable("PATH", path);
    }
}

这在您的控制器和你之前右叫它将创建 LameMP3FileWriter 实例。如果你把它放在的Global.asax.cs 也许工作,并从调用它的Application_Start()。试试吧,让我知道,如果它在那里。

Place that in your controller and call it right before you create the LameMP3FileWriter instance. It might work if you put it in Global.asax.cs and call it from Application_Start(). Try it and let me know if it works there.

我已经把一个Wiki文章关于这个项目工地上的>。

I've put a Wiki article about this on the project site here.

这篇关于MVC4应用"无法加载DLL“libmp3lame.32.dll”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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