如何在我的 C# 网站中使用 LAME (lame_enc.dll)
我正在尝试在我的 C# .NET 网站中使用 lame_enc.dll,但我陷入困境。
我正在使用:.NET Framework 3.5 / Visual Web Developer 2008 Express Edition /(您还需要知道什么吗?)
我做的第一件事是从 代码项目上的 C# MP3 压缩器。我注意到的一件事是,这个项目/帖子是从 2004 年 1 月开始的(所以,它很旧)
我将文件夹“yeti.mmedia”和“yeti.mp3”放在我的“App_Code”目录中,并删除了“Bin”和“obj” ” 每个目录中。然后我尝试构建该项目。当我遇到错误时,我最终从项目中排除了以下文件:
- Yeti.mmedia/AssemblyInfo.cs
- Yeti.mmedia/EditWaveWriter.cs
- Yeti.mmedia/EditWaveWriter.resx
- Yeti.mmedia/InFormatEdit.cs
- Yeti.mmedia/InFormatEdit.resx
- Yeti.mmedia/NumericTextBox.cs
- Yeti.mmedia/NumericTextBox.resx
- Yeti.mmedia/Win32Functions.cs
- Yeti.mp3/AssemblyInfo.cs
- Yeti.mp3/EditMp3Writer.cs
- Yeti.mp3/EditMp3Writer.resx
在我看来,这些是与 Windows UI 相关的代码文件(我现在不需要它)我正在网络上这样做)。
我还将文件“lame_enc.dll”放入Bin目录中。
我根据上面链接的页面上的示例创建了一个测试页面:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using WaveLib;
using Yeti.MMedia;
using Yeti.MMedia.Mp3;
public partial class Documents : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
WaveStream InStr = new WaveStream(Server.MapPath(@"Temp/SomeFile.wav"));
try {
Mp3Writer writer = new Mp3Writer(new FileStream(Server.MapPath(@"Temp/SomeFile.mp3"), FileMode.Create), InStr.Format);
try {
byte[] buff = new byte[writer.OptimalBufferSize];
int read = 0;
while ((read = InStr.Read(buff, 0, buff.Length)) > 0) {
writer.Write(buff, 0, read);
}
}
finally {
writer.Close();
}
}
finally {
InStr.Close();
}
}
}
因此,然后我加载此页面,得到的错误是:
无法加载DLL“Lame_enc.dll”:找不到指定的模块。 (HRESULT 异常:0x8007007E)
(我无法将 DLL 添加为我的项目中的引用,因为它说“...这不是 COM 组件。”)我还尝试获取最新和最好的 (lame3.98.4 ) dll 并有同样的问题。因此,我认为在网站中使用此代码与在其他类型的项目中使用此代码有一些不同。虽然我不知道那是什么。
I am trying to use the lame_enc.dll in my C# .NET website and I am stuck.
I am working with: .NET Framework 3.5 / Visual Web Developer 2008 Express Edition / (Anything else you'd need to know?)
The first thing I did was get the code from C# MP3 Compressor on The Code Project. One thing I noted is that this project/post is from January 2004 (so, it's old)
I put the folders "yeti.mmedia" and "yeti.mp3" in my "App_Code" directory and deleted the "Bin" and "obj" directories within each. Then I tried to build the project. When I got errors I ended up excluding from the project the following files:
- yeti.mmedia/AssemblyInfo.cs
- yeti.mmedia/EditWaveWriter.cs
- yeti.mmedia/EditWaveWriter.resx
- yeti.mmedia/InFormatEdit.cs
- yeti.mmedia/InFormatEdit.resx
- yeti.mmedia/NumericTextBox.cs
- yeti.mmedia/NumericTextBox.resx
- yeti.mmedia/Win32Functions.cs
- yeti.mp3/AssemblyInfo.cs
- yeti.mp3/EditMp3Writer.cs
- yeti.mp3/EditMp3Writer.resx
These seem to me to be the code files related to the Windows UI (which I don't need sonce I'm doing this on the web).
I also put the file "lame_enc.dll" in the Bin directory.
I created a test page based on the example on the page linked above:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using WaveLib;
using Yeti.MMedia;
using Yeti.MMedia.Mp3;
public partial class Documents : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
WaveStream InStr = new WaveStream(Server.MapPath(@"Temp/SomeFile.wav"));
try {
Mp3Writer writer = new Mp3Writer(new FileStream(Server.MapPath(@"Temp/SomeFile.mp3"), FileMode.Create), InStr.Format);
try {
byte[] buff = new byte[writer.OptimalBufferSize];
int read = 0;
while ((read = InStr.Read(buff, 0, buff.Length)) > 0) {
writer.Write(buff, 0, read);
}
}
finally {
writer.Close();
}
}
finally {
InStr.Close();
}
}
}
So, then I load this page and the error I get is:
Unable to load DLL 'Lame_enc.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
(I can't add the DLL as a reference in my project because it says "...This is not a COM component.") I have also tried getting the latest and greatest (lame3.98.4) dll and had the same problems. So, I assume there is something different about using this code in a website rather than another type of project. What it is I don't know though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,由于没有使用 LAME,您必须安装在有问题的盒子上。之后,您应该可以成功使用代码项目代码。如果这不起作用,则表明 Lame_Enc.dll 是本机组件,您将必须使用 PInvoke 方法。
My guess, having not used LAME, is you have to install in on the box in question. After that, you should be able to use the code project code successfully. If that does not work, it appears Lame_Enc.dll is a native component and you will have to PInvoke methods.