我有个外部的ycode.dll,我在asp.net 中就是引用不了,弹出错误的对话框,说是找不到该dll。我在网上找了一大堆资料,也都试了,绝对路径,甚至放在系统system32 下面 都没有用。。
我把代码[贴出来,今天就在这等了,解决后立即结贴using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;using System.Runtime.InteropServices;
public partial class _Default : System.Web.UI.Page 
{
    
    [DllImport("ycode.dll", EntryPoint = "loadcode", SetLastError = true, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
    public static extern int loadcode(int i, int j, string str, string enjoy);
    [DllImport("ycode.dll", EntryPoint = "Recognition")]
    public static extern int Recognition(int i, int j, int a, string str, string enjoy, int b, int c, int d);    [DllImport("ycode.dll", EntryPoint = "Recognitiond")]
    public static extern string Recognitiond(int i, int j, int a, string str, string enjoy);    [DllImport("ycode.dll", EntryPoint = "lstrcpy")]
    public static extern int lstrcpy(string enjoy, int i);    [DllImport("ycode.dll", EntryPoint = "Writepic")]
    public static extern int Writepic(string str);
    protected void Page_Load(object sender, EventArgs e)
    {
        tb.Text = loadcode(0, 0, "例子1.fc", "enjoy-soft").ToString();
    }    protected void Button1_Click(object sender, EventArgs e)
    {
        tb.Text = loadcode(0, 0, "例子1.fc", "enjoy-soft").ToString();
    }    protected void Button2_Click(object sender, EventArgs e)
    {
        //识别,可以根据自己需要设定参数,本例没有输入必须参数,所以采用内部方式读取。        tb.Text = Recognitiond(1, 0, 0, "", "");
        //把图片保存在 c:\code.bmp  以便在控件中显示。
        Writepic("");
        //Image1.Picture.LoadFromFile ("c:\\code.bmp");
        imag.ImageUrl = "c:\\code.bmp";
    }
}

解决方案 »

  1.   

    在自己网站项目的根目录下面新建bin目录,把dll放进去,然后再添加引用---浏览---找到dll后---ok了绝对中
      

  2.   

    需要注册 register ycode.dll ?
      

  3.   

    估计要写注册,再在Bin中引用它!
      

  4.   

    将DLL拷贝到BIN目录后(DLLImport会从程序启动目录开始查找相应名称的DLL,未找到则转至system32下查找),用DllImport来调用
      

  5.   

    没有strong name,不能写入到GAC中,因而,就要注册使用dll如ActiveX
      

  6.   

    把你那个.dll文件放在项目的bin文件下
     
      

  7.   

    你把DLL当到项目的目录里. DLLIMPORT里使用绝对路径看看.
      

  8.   

    已经在bin 下面了。system32 下面 也试了。请各位大仙再看看我的程序有问题吗
      

  9.   

    试试这样吧,我也很无奈啊[DllImport("~/bin/ycode.dll", EntryPoint = "lstrcpy")]
      

  10.   

    放到bin中regsvr32 注册DLL再添加引用就行了