0

我在导入要使用的 DLL 时遇到了很多麻烦。我有一个 aspx 页面,后面没有代码,没有虚拟目录。

关于 DLL,我所知道的只是它的文件名“GenerateExcel.dll”和命名空间“Xander.Utilities”。如何使用其中任何一个导入它

<%@ Assembly Src="./bin/GenerateExcel.dll" %>
<%@ Import Namespace="Xander.Utilities" %>

它不工作。我阅读了 SO 上的其他线程,但仍然遇到问题。

替代文字 http://img406.imageshack.us/img406/8021/62535719.gif

编辑:我这样使用它:

<script runat="server">

        protected void Page_Load(object sender, EventArgs e)
        {
            //...
            Xander.Utilities.ExcelMaker em = new Xander.Utilities.ExcelMaker();
            //...        
        }
4

3 回答 3

2

我不确定这是否可行,因为我没有您的程序集,但您可以尝试使用或不使用 TagPrefix:

<%@ Register Assembly="GenerateExcel" Namespace="Xander.Utilities" TagPrefix="Util" %>
于 2009-09-02T18:23:51.193 回答
1

要从您的程序中调用 dll,您需要包含 System.Runtime.InteropServices 类

尝试:

using System.Runtime.InteropServices 
[DllImport("name.dll")]
private static extern int FunctionNameInDll();
于 2009-09-02T18:22:52.507 回答
1

答案是做一个<%@ Import Namespace="Xander.Utilities" %>,然后将 DLL 放在根目录的 bin 文件夹中。

于 2009-09-03T15:21:21.143 回答