[英]Use an assembly in an aspx page
I have a very simple aspx script: 我有一个非常简单的aspx脚本:
<%@ Page Language="C#" Debug="true" %>
<%@ Assembly Name="MimeKit.dll" %>
<%
Response.Write("test");
%>
The MimeKit.dll is in the same folder as this script. MimeKit.dll与此脚本位于同一文件夹中。
I find answers that tell me to put it in the bin folder. 我找到的答案告诉我把它放在bin文件夹中。 I don't have a bin folder, this is just a single file - not created in Visual Studio and not part of a project or app. 我没有bin文件夹,这只是一个文件 - 不是在Visual Studio中创建的,不是项目或应用程序的一部分。
Can anyone tell me what I need to do, that does not involve using Visual studio, to be able to use this dll. 任何人都可以告诉我我需要做什么,不涉及使用Visual Studio,能够使用这个DLL。
I get error: 我收到错误:
Could not load file or assembly 'MimeKit.dll' or one of its dependencies. The system cannot find the file specified.
I run the script like so: 我像这样运行脚本:
http://localhost/test/mail.aspx
I have created a bin folder at http://localhost/bin and put the dll in there. 我在http:// localhost / bin创建了一个bin文件夹,并将dll放在那里。 I have also created a bin folder at http://localhost/test/bin . 我还在http:// localhost / test / bin创建了一个bin文件夹。 I get the same error. 我犯了同样的错误。
Have also tried: 也尝试过:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\gacutil.exe" /i MimeKit.dll
which said it was successful, but still I get the same error. 它说这是成功的,但我仍然得到同样的错误。
Also did the gacutil using the Developer Command Prompt for VS 2017 - made no difference. 使用VS 2017开发人员命令提示符的gacutil也没有任何区别。
Also added the following to web.config: 还将以下内容添加到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>
Still no go - same error message. 仍然没有去 - 相同的错误信息。 (Note: I got the public key token by using gacutil /l MimeKit
. (注意:我使用gacutil /l MimeKit
公钥令牌。
Discovered that MimeKit has a dependency (BouncyCastle.Crypto.dll), so tried just using that: 发现MimeKit有一个依赖(BouncyCastle.Crypto.dll),所以尝试使用它:
<%@ Page Language="C#" Debug="true" %>
<%@ Assembly Name="BouncyCastle.Crypto.dll" %>
<%
Response.Write("test");
%>
Same error and this has no dependencies. 相同的错误,这没有依赖性。
Pulling my hair out - does anyone know how to do this? 拉出我的头发 - 有谁知道怎么做?
OK - I was barking up the wrong tree. 好的 - 我正在咆哮错误的树。 This is what I needed. 这就是我需要的。 Didn't need to register the dll, just needed to put it in the folder: http://localhost/bin 不需要注册dll,只需将它放在文件夹中: http:// localhost / bin
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="MimeKit" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.