0

我正在尝试从 .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 文件。我有以下内容bin\Debug\

  • 平衡.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 文件。Balanced.dll 是一个外部库。它只是附带文件和 .csproj 文件。我做了一个构建,现在我正在尝试使用这个 Balanced.dll 文件。我错过了什么吗?如果这是一个不好的问题,我很抱歉。我是 asp.net 和 csproj 的新手。

4

1 回答 1

0

你不能那样做。您需要指定命名空间,而不是 src。src 用于项目中的用户控件/服务器控件。

您的命名空间值将取决于 DLL 的编译方式及其命名空间的结构。

此外,在这种情况下,您不指定 tagName。tagName 将是 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" %>
于 2013-09-30T04:43:28.917 回答