【问题标题】:C# smo project assembly not referenced errorC# smo 项目程序集未引用错误
【发布时间】:2012-04-01 14:21:51
【问题描述】:

我正在做一个使用 smo 对象(服务器、数据库)的 C# 项目。
我包括了

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Server;  

我已添加 Microsoft.SqlServer.Management.Smo、Microsoft.SqlServer.Management.SmoExtended、Microsoft.SqlServer.SqlEnum、Microsoft.SqlServer.ConnectionInfo。

但我仍然收到这样的错误(10 个类似的错误):

The type 'Microsoft.SqlServer.Management.Sdk.Sfc.ISfcHasConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.  

如何解决这个问题??

【问题讨论】:

    标签: c# sql-server assemblies smo


    【解决方案1】:

    嗯,我认为这个错误很容易解释,包括对Microsoft.SqlServer.Management.Sdk.Sfc 的引用。您没有列出您添加了该引用。有时,当您添加使用未包含的其他 dll 引用的引用时,您必须包含这些其他引用......即使您没有使用它们。

    【讨论】:

      【解决方案2】:

      我不知道您的问题是否仍然存在,但就我而言,问题是 App.Config 中的程序集绑定重定向:

      <startup>
          <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        </startup>
        <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
              <assemblyIdentity name="Microsoft.SqlServer.Management.Sdk.Sfc" publicKeyToken="89845dcd8080cc91" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-15.100.0.0" newVersion="15.100.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="Microsoft.SqlServer.ConnectionInfo" publicKeyToken="89845dcd8080cc91" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-15.100.0.0" newVersion="15.100.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="Microsoft.SqlServer.Diagnostics.STrace" publicKeyToken="89845dcd8080cc91" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-15.100.0.0" newVersion="15.100.0.0" />
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="Microsoft.SqlServer.Smo" publicKeyToken="89845dcd8080cc91" culture="neutral" />
              <bindingRedirect oldVersion="0.0.0.0-15.100.0.0" newVersion="15.100.0.0" />
            </dependentAssembly>
          </assemblyBinding>
        </runtime>
      

      我不知道 Visual Studio 是什么时候把它放在这里的,但是,当我删除它时,它就可以工作了。

      =)

      【讨论】:

        猜你喜欢
        • 2016-08-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-14
        • 1970-01-01
        相关资源
        最近更新 更多