2017-07-26 56 views
1

问题很简单。我将WebApps项目移至安装了Microsoft.SqlServer.Types nuget软件包的Service Fabric。现在,当试图访问数据库时,我收到以下错误,因为我正在使用空间类型。带服务结构的Microsoft.SqlServer.Types

“空间类型和功能不适用于该供应商是因为程序集‘Microsoft.SqlServer.Types’10或更高版本找不到。”

我试着加入以下一行代码添加到FabricRuntime创建实例的类中,但没用。

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory); 

您的帮助将不胜感激,请让我知道如果您需要我的更多信息。

回答

1

你确实需要的代码行,但对于asp.net应用程序应该是略有不同: 对于Asp.net网站,Default.aspx.cs:

public partial class _Default : System.Web.UI.Page 
{ 
    static bool _isSqlTypesLoaded = false; 

    public _Default() 
    { 
     if (!_isSqlTypesLoaded) 
     { 
      SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~")); 
      _isSqlTypesLoaded = true; 
     } 

    } 
} 

对于Web应用程序,在全球.asax.cs:

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin")); 

而且你需要在web.config中创建以下绑定重定向:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" /> 
    </dependentAssembly> 
    </assemblyBinding> 
</runtime> 

Here是关于该主题的唯一帮助。

更新:Here是一个博客文章,提供了一个很好的描述解决方案的3个步骤。虽然第三步不适用于我,但我必须如上所述创建绑定。

+0

谢谢!这个问题的一个小的变化固定我的问题,你可以在这里找到它:https://github.com/Azure/service-fabric-issues/issues/369 – haseebahmed7