你确实需要的代码行,但对于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个步骤。虽然第三步不适用于我,但我必须如上所述创建绑定。
谢谢!这个问题的一个小的变化固定我的问题,你可以在这里找到它:https://github.com/Azure/service-fabric-issues/issues/369 – haseebahmed7