无法在 Windows Server 2008 R2 中 运行 dotnet core 2 控制台应用程序
Unable to run dotnet core 2 console app in Windows Server 2008 R2
我正在使用 TopShelf 和 dotnet core 2 框架开发 windows 服务应用程序。为了创建它,我使用了 Console App (.NET core) 模板。现在,为了部署应用程序,我创建了一个发布配置文件以在本地执行。这是内容:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishDir>C:\Repos\Deployments\MassTransit.Consumer</PublishDir>
<Platform>Any CPU</Platform>
<SelfContained>true</SelfContained>
<_IsPortable>true</_IsPortable>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
如您所见,RuntineIdentifier 是 win7-x64,根据 documentation 这应该是 运行 中应用程序的正确标识符Windows 服务器 2008 R2。当我将应用程序部署到本地文件夹时,我可以 运行 它在我的机器上执行生成的 .exe 时没有问题,但是当我尝试 运行 它在 Windows 服务器 2008 R2 中时,复制windows 服务器中本地文件夹的所有文件,我得到 badimageformatexception bad il format error:
在windows服务器安装了Dotnetcore.2.0.5-WindowsHosting和Dotnet-sdk-2.1.105- win64
仅供参考,我在此服务器的 IIS 下有一个 Web api 核心 2 应用程序 运行,如果我 运行 dotnet --version 在 cmd.exe 它 returns 2.1.0.105,所以它识别安装了 dotnet 核心
关于控制台应用程序为什么在 Windows Server 2008 R2 中 运行 出现该错误的任何线索。我还需要安装其他东西吗?或者,我需要更改我的发布配置文件中的某些内容吗?
更新
我很确定异常发生在 Load.From
:
的黄线上
我正在使用该代码加载自定义库,这些库具有我需要在应用程序启动时注册的 Autofac 模块。
这不是服务器的问题。这是因为我要匹配的模式包含在文件名中,这是一个路径,所以它加载了错误的程序集,如 hostfrx.dll
和 hostpolicy.dll
:
它是 运行 本地的,因为一旦我部署了项目,这个程序集就会出现。
我正在使用 TopShelf 和 dotnet core 2 框架开发 windows 服务应用程序。为了创建它,我使用了 Console App (.NET core) 模板。现在,为了部署应用程序,我创建了一个发布配置文件以在本地执行。这是内容:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishDir>C:\Repos\Deployments\MassTransit.Consumer</PublishDir>
<Platform>Any CPU</Platform>
<SelfContained>true</SelfContained>
<_IsPortable>true</_IsPortable>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
如您所见,RuntineIdentifier 是 win7-x64,根据 documentation 这应该是 运行 中应用程序的正确标识符Windows 服务器 2008 R2。当我将应用程序部署到本地文件夹时,我可以 运行 它在我的机器上执行生成的 .exe 时没有问题,但是当我尝试 运行 它在 Windows 服务器 2008 R2 中时,复制windows 服务器中本地文件夹的所有文件,我得到 badimageformatexception bad il format error:
在windows服务器安装了Dotnetcore.2.0.5-WindowsHosting和Dotnet-sdk-2.1.105- win64
仅供参考,我在此服务器的 IIS 下有一个 Web api 核心 2 应用程序 运行,如果我 运行 dotnet --version 在 cmd.exe 它 returns 2.1.0.105,所以它识别安装了 dotnet 核心
关于控制台应用程序为什么在 Windows Server 2008 R2 中 运行 出现该错误的任何线索。我还需要安装其他东西吗?或者,我需要更改我的发布配置文件中的某些内容吗?
更新
我很确定异常发生在 Load.From
:
我正在使用该代码加载自定义库,这些库具有我需要在应用程序启动时注册的 Autofac 模块。
这不是服务器的问题。这是因为我要匹配的模式包含在文件名中,这是一个路径,所以它加载了错误的程序集,如 hostfrx.dll
和 hostpolicy.dll
:
它是 运行 本地的,因为一旦我部署了项目,这个程序集就会出现。