我正在尝试从.aspx网页引用.dll文件。 但是,我收到以下错误:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: There is no build provider registered for the extension '.dll'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Source Error:
Line 2: <%@ Page Title="" Language="C#" MasterPageFile="CSharpBPTestMaster.master" AutoEventWireup="true" CodeFile="CSharpBPTest.aspx.cs" Inherits="Button" Debug="true"%>
Line 3:
Line 4: <%@ Register tagprefix="blnc" tagname="Balanced" src="bin/Debug/BalancedTest.dll" %>
Line 5:
Line 6:
Source File: /preview/1/balanced-csharp-master/src/BalancedTest/CSharpBPTest.aspx Line: 4
我不确定我做错了什么。 我构建了 .csproj 文件。 我有以下binDebug
:
- 平衡.dll
- 平衡.pdb
- 平衡测试.dll
- 平衡测试.pdb
这是我的CSharpBPTest.aspx
:
<%@ Page Title="" Language="C#" MasterPageFile="CSharpBPTestMaster.master" AutoEventWireup="true" CodeFile="CSharpBPTest.aspx.cs" Inherits="Button" Debug="true"%>
<%@ Register tagprefix="blnc" tagname="Balanced" src="bin/Debug/BalancedTest.dll" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<form id="form1" runat="server">
<div>
<asp:Button ID="button1" runat="server" Text="Submit" OnClick="Button_Command"/>
<br />
<br />
<br><asp:label id="warningLabel" Text="" ForeColor="Red" runat="server"/><br>
<br />
</div>
</form>
</asp:Content>
在我的 C# 文件中,我像这样"导入"项目(在顶部):
using Balanced;
我希望能够在我的 C# 端使用这个编译的.dll文件。 平衡.dll是一个外部库。 它只是附带文件和一个.csproj文件。 我做了一个构建,现在我正在尝试使用这个平衡.dll文件。 我错过了什么吗? 如果这是一个糟糕的问题,我很抱歉。 我是 asp.net 和csproj的新手。
那样做。您需要指定命名空间,而不是 src。 SRC 用于项目中的用户控件/服务器控件。
命名空间值将取决于 DLL 的编译方式及其命名空间的结构。
此外,在这种情况下,您不指定标签名称。 标记名称将是 DLL 控件的类名。
一个非常基本的例子是:
<%-- assumes that 'BalancedTest' is the namespace that this control is in, and that the BalancedTest.dll already has a class that inherits UserControl (or a child of it) with the name 'BalancedTest'. --%>
<%@ Register tagprefix="blnc" Namespace="BalancedTest" %>