【问题标题】:C# Windows Service wont install if it includes (embedded) Entity Framework如果 C# Windows 服务包含(嵌入式)实体框架,则不会安装
【发布时间】:2017-04-15 19:29:50
【问题描述】:

我一直在试图找出为什么我的 C# Windows 服务无法安装,这似乎是由包含实体框架引起的。

为了测试这一点,我使用 Visual Studio 中的 Windows 服务模板创建了一个新项目,然后让向导完成它的工作。

部署到我的测试服务器,安装完毕,一切正常……然后我卸载了。

接下来,我将(DB First)实体框架模型添加到项目中,这也是一个非常基本的模型并部署到服务器上。

这一次,当我安装时,我得到以下..

Microsoft (R) .NET Framework 安装实用程序版本 4.0.30319.17929 版权所有 (C) Microsoft Corporation。保留所有权利。

运行事务安装。

开始安装的安装阶段。看内容 D:\SandBox\TestService\TestService.exe 程序集的日志文件 进步。该文件位于 D:\SandBox\TestService\TestService.InstallLog。安装组件 'D:\SandBox\TestService\TestService.exe'。受影响的参数有:
登录控制台 = 日志文件 = D:\SandBox\TestService\TestService.InstallLog 程序集路径 = D:\SandBox\TestService\TestService.exe 发生异常时 试图在 D:\SandBox\TestService\TestService.exe 程序集。 System.Reflection.ReflectionTypeLoadException:无法加载一个或 更多请求的类型。检索 LoaderExceptions 属性 了解更多信息。中止安装 D:\SandBox\TestService\TestService.exe。

安装阶段发生异常。 System.InvalidOperationException:无法在 D:\SandBox\TestService\TestService.exe 程序集。内在异常 System.Reflection.ReflectionTypeLoadException 被抛出 以下错误消息:无法加载一个或多个请求 类型。检索 LoaderExceptions 属性以获取更多信息。

安装的回滚阶段即将开始。查看内容 D:\SandBox\TestService\TestService.exe 的日志文件 大会的进展。该文件位于 D:\SandBox\TestService\TestService.InstallLog。回滚组件 'D:\SandBox\TestService\TestService.exe'。受影响的参数有:
登录控制台 = 日志文件 = D:\SandBox\TestService\TestService.InstallLog 程序集路径 = D:\SandBox\TestService\TestService.exe 发生异常时 试图在 D:\SandBox\TestService\TestService.exe 程序集。 System.Reflection.ReflectionTypeLoadException:无法加载一个或 更多请求的类型。检索 LoaderExceptions 属性 了解更多信息。中止安装 D:\SandBox\TestService\TestService.exe。期间发生异常 的回滚阶段 System.Configuration.Install.AssemblyInstaller 安装程序。 System.InvalidOperationException:无法在 D:\SandBox\TestService\TestService.exe 程序集。内在异常 System.Reflection.ReflectionTypeLoadException 被抛出 以下错误消息:无法加载一个或多个请求 类型。检索 LoaderExceptions 属性以获取更多信息。 在安装的回滚阶段发生异常。 此异常将被忽略,回滚将继续。 但是,机器可能不会完全恢复到其初始状态后 回滚完成。

回滚阶段成功完成。

事务安装已完成。安装失败,并且 已执行回滚。

部署服务时,我使用 execonfig 复制了 EntityFramework.dllEntityFramework.SqlServer.dll 个文件,并且都在同一个文件夹中。

那么,InstallUtil 明确抱怨的是什么。我怎样才能知道

仅供参考:根据任何开发人员问题“在我的机器上工作”

编辑:

对这个 SO 问题 Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.' 的引用是在 RUNTIME 期间出现问题时......我的具体问题是在 INSTALL

期间

【问题讨论】:

标签: c# entity-framework windows-services installutil


【解决方案1】:

嗯,我已经设法解决/解决了这个问题。

我没有在服务应用程序中使用 EF 模型,而是将其分离到自己的类库中,然后将其添加为参考,瞧,安装成功。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多