在 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 and put the dll in there. I have also created a bin folder at 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
上面说成功了,但是我还是报同样的错误。
gacutil 也使用 VS 2017 的开发人员命令提示符 - 没有区别。
还在 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
.
获得了 public 密钥令牌
发现 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" %>
我有一个非常简单的 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 and put the dll in there. I have also created a bin folder at 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
上面说成功了,但是我还是报同样的错误。
gacutil 也使用 VS 2017 的开发人员命令提示符 - 没有区别。
还在 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" %>