繁体   English   中英

在aspx页面中使用程序集

[英]Use an assembly in an aspx page

我有一个非常简单的aspx脚本:

<%@ Page Language="C#" Debug="true" %>
<%@ Assembly Name="MimeKit.dll" %>
<%
Response.Write("test");
%>

MimeKit.dll与此脚本位于同一文件夹中。

我找到的答案告诉我把它放在bin文件夹中。 我没有bin文件夹,这只是一个文件 - 不是在Visual Studio中创建的,不是项目或应用程序的一部分。

任何人都可以告诉我我需要做什么,不涉及使用Visual Studio,能够使用这个DLL。

我收到错误:

Could not load file or assembly 'MimeKit.dll' or one of its dependencies. The system cannot find the file specified.

我像这样运行脚本:

http://localhost/test/mail.aspx

我在http:// localhost / bin创建了一个bin文件夹,并将dll放在那里。 我还在http:// localhost / test / bin创建了一个bin文件夹。 我犯了同样的错误。

也尝试过:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\gacutil.exe" /i MimeKit.dll

它说这是成功的,但我仍然得到同样的错误。

使用VS 2017开发人员命令提示符的gacutil也没有任何区别。

还将以下内容添加到web.config:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="myAssembly" publicKeyToken="bede1c8a46c66814" culture="neutral" />
            <codeBase version="2.1.0.0" href="http://localhost/bin/MimeKit.dll"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

仍然没有去 - 相同的错误信息。 (注意:我使用gacutil /l MimeKit公钥令牌。

发现MimeKit有一个依赖(BouncyCastle.Crypto.dll),所以尝试使用它:

<%@ Page Language="C#" Debug="true" %>
<%@ Assembly Name="BouncyCastle.Crypto.dll" %>
<%
Response.Write("test");
%>

相同的错误,这没有依赖性。

拉出我的头发 - 有谁知道怎么做?

好的 - 我正在咆哮错误的树。 这就是我需要的。 不需要注册dll,只需将它放在文件夹中: http:// localhost / bin

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="MimeKit" %>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM