如何在我的C#网站上使用LAME(lame_enc.dll)

Hew*_*ins 5 .net c# lame

我试图在我的C#.NET网站中使用lame_enc.dll而且我被卡住了.

我正在使用:.NET Framework 3.5/Visual Web Developer 2008 Express Edition /(您还需要知道其他什么吗?)

我做的第一件事是从代码项目的C#MP3 Compressor获取代码.我注意到的一件事是这个项目/职位是从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();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

所以,然后我加载这个页面,我得到的错误是:

无法加载DLL'Lame_enc.dll':找不到指定的模块.(来自HRESULT的异常:0x8007007E)

(我不能在我的项目中添加DLL作为参考,因为它说"......这不是COM组件.")我也试过获得最新最好的(lame3.98.4)dll并遇到同样的问题.因此,我假设在网站中使用此代码而不是其他类型的项目存在一些不同之处.但是我不知道它是什么.

Gre*_*mer 1

我的猜测是,由于没有使用 LAME,您必须安装在有问题的盒子上。之后,您应该可以成功使用代码项目代码。如果这不起作用,则表明 Lame_Enc.dll 是本机组件,您将必须使用 PInvoke 方法。