C# Windows 如果服务包含(嵌入式)Entity Framework,则不会安装该服务
C# Windows Service wont install if it includes (embedded) Entity Framework
我一直在尝试找出为什么我的 C# Windows 服务无法安装,这似乎是由包含 Entity Framework.
引起的
为了对此进行测试,我使用 Visual Studio 中的 Windows 服务模板创建了一个新项目,然后让向导执行它的操作。
部署到我的测试服务器,安装并且一切正常...然后我卸载了。
接下来,我向项目添加了(DB First)Entity Framework 模型,同样是一些非常基本的模型并部署到服务器..
这次,当我安装时,我得到以下信息..
Microsoft (R) .NET Framework Installation utility Version
4.0.30319.17929 Copyright (C) Microsoft Corporation. All rights reserved.
Running a transacted installation.
Beginning the Install phase of the installation. See the contents of
the log file for the D:\SandBox\TestService\TestService.exe assembly's
progress. The file is located at
D:\SandBox\TestService\TestService.InstallLog. Installing assembly
'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile =
D:\SandBox\TestService\TestService.InstallLog assemblypath =
D:\SandBox\TestService\TestService.exe An exception occurred while
trying to find the installers in the
D:\SandBox\TestService\TestService.exe assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or
more of the requested types. Retrieve the LoaderExceptions property
for more information. Aborting installation for
D:\SandBox\TestService\TestService.exe.
An exception occurred during the Install phase.
System.InvalidOperationException: Unable to get installer types in the
D:\SandBox\TestService\TestService.exe assembly. The inner exception
System.Reflection.ReflectionTypeLoadException was thrown with the
following error message: Unable to load one or more of the requested
types. Retrieve the LoaderExceptions property for more information..
The Rollback phase of the installation is beginning. See the contents
of the log file for the D:\SandBox\TestService\TestService.exe
assembly's progress. The file is located at
D:\SandBox\TestService\TestService.InstallLog. Rolling back assembly
'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile =
D:\SandBox\TestService\TestService.InstallLog assemblypath =
D:\SandBox\TestService\TestService.exe An exception occurred while
trying to find the installers in the
D:\SandBox\TestService\TestService.exe assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or
more of the requested types. Retrieve the LoaderExceptions property
for more information. Aborting installation for
D:\SandBox\TestService\TestService.exe. An exception occurred during
the Rollback phase of the
System.Configuration.Install.AssemblyInstaller installer.
System.InvalidOperationException: Unable to get installer types in the
D:\SandBox\TestService\TestService.exe assembly. The inner exception
System.Reflection.ReflectionTypeLoadException was thrown with the
following error message: Unable to load one or more of the requested
types. Retrieve the LoaderExceptions property for more information..
An exception occurred during the Rollback phase of the installation.
This exception will be ignored and the rollback will continue.
However, the machine might not fully revert to its initial state after
the rollback is complete.
The Rollback phase completed successfully.
The transacted install has completed. The installation failed, and the
rollback has been performed.
部署服务时,我复制了 EntityFramework.dll 和 EntityFramework.SqlServer.dll 以及 exe 和 config 文件,并且都在同一个文件夹中。
那么,InstallUtil 明确抱怨的是什么。我怎样才能知道
仅供参考:"Works on my machine" 根据任何开发者问题
编辑:
对这个 SO 问题 Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.' 的引用是在 RUNTIME 期间出现问题时...我的具体问题是在 INSTALL[=47= 期间]
好吧,我已经设法 resolve/work 解决了这个问题。
我没有在服务应用程序中使用 EF 模型,而是将其放入自己的 class 库中,然后将其添加为参考,瞧,安装成功。
我一直在尝试找出为什么我的 C# Windows 服务无法安装,这似乎是由包含 Entity Framework.
引起的为了对此进行测试,我使用 Visual Studio 中的 Windows 服务模板创建了一个新项目,然后让向导执行它的操作。
部署到我的测试服务器,安装并且一切正常...然后我卸载了。
接下来,我向项目添加了(DB First)Entity Framework 模型,同样是一些非常基本的模型并部署到服务器..
这次,当我安装时,我得到以下信息..
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.17929 Copyright (C) Microsoft Corporation. All rights reserved.
Running a transacted installation.
Beginning the Install phase of the installation. See the contents of the log file for the D:\SandBox\TestService\TestService.exe assembly's progress. The file is located at D:\SandBox\TestService\TestService.InstallLog. Installing assembly 'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile = D:\SandBox\TestService\TestService.InstallLog assemblypath = D:\SandBox\TestService\TestService.exe An exception occurred while trying to find the installers in the D:\SandBox\TestService\TestService.exe assembly. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Aborting installation for D:\SandBox\TestService\TestService.exe.An exception occurred during the Install phase. System.InvalidOperationException: Unable to get installer types in the D:\SandBox\TestService\TestService.exe assembly. The inner exception System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..
The Rollback phase of the installation is beginning. See the contents of the log file for the D:\SandBox\TestService\TestService.exe assembly's progress. The file is located at D:\SandBox\TestService\TestService.InstallLog. Rolling back assembly 'D:\SandBox\TestService\TestService.exe'. Affected parameters are:
logtoconsole = logfile = D:\SandBox\TestService\TestService.InstallLog assemblypath = D:\SandBox\TestService\TestService.exe An exception occurred while trying to find the installers in the D:\SandBox\TestService\TestService.exe assembly. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Aborting installation for D:\SandBox\TestService\TestService.exe. An exception occurred during the Rollback phase of the System.Configuration.Install.AssemblyInstaller installer. System.InvalidOperationException: Unable to get installer types in the D:\SandBox\TestService\TestService.exe assembly. The inner exception System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete.The Rollback phase completed successfully.
The transacted install has completed. The installation failed, and the rollback has been performed.
部署服务时,我复制了 EntityFramework.dll 和 EntityFramework.SqlServer.dll 以及 exe 和 config 文件,并且都在同一个文件夹中。
那么,InstallUtil 明确抱怨的是什么。我怎样才能知道
仅供参考:"Works on my machine" 根据任何开发者问题
编辑:
对这个 SO 问题 Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.' 的引用是在 RUNTIME 期间出现问题时...我的具体问题是在 INSTALL[=47= 期间]
好吧,我已经设法 resolve/work 解决了这个问题。
我没有在服务应用程序中使用 EF 模型,而是将其放入自己的 class 库中,然后将其添加为参考,瞧,安装成功。