[英]How to add a reference to System.Data.DataSetExtensions to a Web Site ascx.cs file?
We're working with a Web Site project and trying to reference System.Data.DataSetExtensions
. 我们正在使用Web站点项目并尝试引用
System.Data.DataSetExtensions
。 (Using a Web Application would be better; the technical lead, though, has her reasons.) (使用Web应用程序会更好;但技术主管有她的理由。)
Here is what we have tried: 这是我们尝试过的:
sn.exe -T "full\\path.dll"
sn.exe -T "full\\path.dll"
web.config > system.web > web.config> system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<!-- Other assemblied omitted -->
<add assembly="System.Data.DataSetExtensions,
Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
The full path is C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Data.DataSetExtensions.dll
完整路径是
C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Data.DataSetExtensions.dll
Despite this, msbuild still complains when we add using System.Data.DataSetExtensions
to a code behind file. 尽管如此,当我们将
using System.Data.DataSetExtensions
添加到代码隐藏文件时,msbuild仍然会抱怨。 What gives? 是什么赋予了? How do we solve this?
我们如何解决这个问题?
The problem was our using
statement. 问题是我们的
using
声明。 So, there were two requirements. 所以,有两个要求。
System.Data.DataSetExtensions
in the web.config file. System.Data.DataSetExtensions
。 (See below for finding the full assembly name.) using
statement for System.Data
in the C# file. System.Data
添加using
语句。 The problem was that our using statement was for System.Data.DataSetExtensions
. 问题是我们的using语句用于
System.Data.DataSetExtensions
。
Rick Strahl explains that by default ASP.NET includes: Rick Strahl解释说默认情况下ASP.NET包括:
bin
path bin
路径中的所有程序集 <compilation>
section <compilation>
部分中的任何基于GAC的程序集引用 Further, we were able to query to GAC from a Visual Studio Command Prompt as follows: 此外,我们能够从Visual Studio命令提示符查询GAC,如下所示:
> gacutil /l System.Data.DataSetExtensions
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.17929
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
Number of items = 2
This confirmed that the assembly we wanted was in the GAC. 这证实了我们想要的程序集在GAC中。 It also listed the full name of the assembly that we needed to reference in the web.config file.
它还列出了我们需要在web.config文件中引用的程序集的全名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.