繁体   English   中英

未找到 EF6 方法 set_SqlServerTypesAssemblyNames

[英]EF6 Method not found set_SqlServerTypesAssemblyNames

我在将控制台应用程序部署到服务器上时遇到了困难。

我正在使用 EF6 (6.3.0) 和 SqlServerTypes 14 (14.0.1016.290) 并在按照建议进行任何空间调用之前进行初始化

SqlProviderServices.SqlServerTypesAssemblyName = Assembly.GetAssembly(typeof(Microsoft.SqlServer.Types.SqlGeography)).FullName; //"Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

但是在 setter 行,抛出以下错误

System.MissingMethodException:找不到方法:'无效 System.Data.Entity.SqlServer.SqlProviderServices.set_SqlServerTypesAssemblyName(System.String)'。

我确保 SqlServerTypes dll 存在于 bin 目录中。

我读到 EF6 只支持我尝试过的 SqlServerTypes 11,但是没有运气。

应用程序在本地运行良好。

编辑:我现在已经在服务器上安装了 SQL 服务器系统 CLR 类型,但无济于事。

当您的开发运行时和部署环境在 GAC 中安装了不同版本的软件包并且并非开发环境中的所有 dll 都复制到部署环境中时,可能会发生此错误(以及其他类似错误)。

这个问题有可能有用的指导: EntityFramework.SqlServer.dll not is getting added to the published folder only when I publish in RELEASE mode

  • My preferred workaround is to follow this advice and make a code reference to a class or function within each of the DLLs that you depend on to 'trick' visual studio into including the dll in the output by default AND to force a compile time error if该组件不可用(在通过注入使用 DLL 的情况下很有用)。

如果您不知道哪个 dll 可能是原因并且应用程序在开发中运行良好,那么一个简单的修复可以是将所有引用标记为 Copy Local = True:

复制本地真

然后,如果可行,您可以从 output 中删除您认为不需要的 DLL,反复测试该应用程序是否仍在运行,直到您找到需要部署的最小 dll 集

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM