无法在项目和服务器上获得 Target .NET Framework 以达成一致
Can't get Target .NET Framework in Project and on Server to Agree
我在 Azure 上托管了一个应用程序,该应用程序是使用 Lightswitch Silverlight 客户端构建的。我最近去更新它并用基于 HTML 的客户端替换它。但是在成功发布到 Azure 并尝试访问该站点后,我收到以下错误:
我试图打开旧的 Silverlight 项目,但我已经升级到 Visual Studio 2015,所以它想升级项目。那失败得很惨。经过大量手动修改后,我也能够发布它,但是当我尝试访问它时收到相同的错误消息。我已启用详细跟踪,但尝试访问跟踪会导致相同的错误。
我之前在发布时遇到过问题 (example 1, example 2)。但是 none 这些技巧这次似乎奏效了。我真的不希望他们这样做,因为错误完全不同。
我终于接受了错误消息的建议并添加了 customErrors
行。这导致了以下网页:
没有换行的最后一行如下:
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
我感觉这与服务器上安装的 .NET 框架有关。所以昨天我试图创建一个远程桌面连接。然而,这导致发布失败,并出现错误,说明它不受支持或其他内容。我没有抄下来。今天我再次尝试,无论出于何种原因,我都能够获得 RD 连接。不确定是什么问题或发生了什么变化。
服务器是 Windows Server 2012,没有安装 .NET 4.6 的选项,只有 4.5 已安装。所以我更改了错误页面提示的行,使编译行的 targetFramework
为 4.5 而不是 4.6 并再次发布。我这样做是因为我无法更改服务器属性页面中的框架:
现在我收到以下错误消息:
完整的堆栈跟踪是:
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
Microsoft.LightSwitch.BaseServices.Logging.Utilities.HostEnvironment.RunningInAzureCore() +0
Microsoft.LightSwitch.BaseServices.Logging.Utilities.HostEnvironment.RunningInAzure() +121
Microsoft.LightSwitch.BaseServices.Configuration.Utilities.ServerSettings.TryGetSetting(String settingName, Boolean availableInAzureConfig, T& value) +21
Microsoft.LightSwitch.BaseServices.Configuration.Utilities.SettingsManager.GetSettingOrDefault(String settingName, TryGetSettingsDelegate`1 tryGetSettingsFunc, Func`1 getDefaultValue) +37
Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.Init(HttpApplication application) +25
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +618
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712
我终于能够解决服务器上的所有安全问题并安装 .NET 4.6。这让我通过了 'Configuration Error',但给我留下了 'Could not load' 错误。
此错误声称项目正在寻找 Microsoft.WindowsAzure.ServiceRuntime Version 2.8.0.0
。查看我的服务器,是运行Version 2.7.1198.738
。这就是导致它找不到正确版本的原因。
但是我觉得奇怪的是,在我的项目中我只有Microsoft.WindowsAzure.ServiceRuntime.dll Version 2.1.1196.512
。尽管它不在我的任何参考文献中。如果我尝试将其添加为参考,我只能访问版本 2.7.0.0。我也不确定如何在项目中更改它。 grep
在我的项目中使用它只会提取二进制文件,所以我不知道如何更改那里的版本。
然后我下载了 Web 平台安装程序并安装了 Azure SDK 2.8.1,我认为它也在该服务器上安装了 Visual Studio。不知道如何从这个东西中卸载程序,但无论如何。不幸的是,该模块仍然报告为版本 2.7.1196.512 并且尝试访问该网站时出现相同的错误。
不太确定从这里到哪里去。我需要更新服务器上的模块或更改项目中的目标。我也不知道该怎么做,而且找不到资源。
文件 ./ProjectName/Bin/Debug/app.publish/web.config
包含以下几行:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="2.1.0.0" newVersion="2.8.0.0" />
</dependentAssembly>
这显然是在发布时生成的。我的项目中的Web.config
,我可以编辑的Web.config
,没有提到Microsoft.WindowsAzure.ServiceRuntime
。我在网上看到一些地方说我应该添加一个并更改版本号以适用。所以我添加了以下内容:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="2.7.0.0" newVersion="2.7.0.0" />
</dependentAssembly>
因为我的服务器显然没有版本 2.1.0.0 或 2.8.0.0,但有版本 2.7.1196.512。但是,当我发布时,生成的 web.config
仍然具有相同的版本号,并且当我尝试访问它时仍然遇到相同的错误。
如何更改此引用的版本?
根据 MSDN 论坛上 MS 员工的建议,我将 Web.config 更改为以下内容:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0" />
</dependentAssembly>
我已经更新了上面的 无法加载文件或程序集 错误的图片。但这里是堆栈跟踪的相关部分:
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
所以现在它正在寻找两个不同的版本,但都找不到。正确的版本似乎是 2.7.0.0。这就是它在引用 dll 的属性 window 中所说的。 Copy Local也被确认设置为True。
bin
文件夹和 C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.8\bin\runtimes\base
中的 dll 文件的完整版本在我的本地机器和我的服务器上都是 2.7.1198.738。
原来微软从 Azure SDK 中删除了将 Lightswitch 应用程序发布到 Azure 云服务的功能,没有通知任何人,也没有将其放入 Microsoft Office 开发人员工具中(a.k.a .Lightswitch SDK),正如他们计划的那样。
解决方案是部署为 Web 应用程序而不是云服务。
我在 Azure 上托管了一个应用程序,该应用程序是使用 Lightswitch Silverlight 客户端构建的。我最近去更新它并用基于 HTML 的客户端替换它。但是在成功发布到 Azure 并尝试访问该站点后,我收到以下错误:
我试图打开旧的 Silverlight 项目,但我已经升级到 Visual Studio 2015,所以它想升级项目。那失败得很惨。经过大量手动修改后,我也能够发布它,但是当我尝试访问它时收到相同的错误消息。我已启用详细跟踪,但尝试访问跟踪会导致相同的错误。
我之前在发布时遇到过问题 (example 1, example 2)。但是 none 这些技巧这次似乎奏效了。我真的不希望他们这样做,因为错误完全不同。
我终于接受了错误消息的建议并添加了 customErrors
行。这导致了以下网页:
没有换行的最后一行如下:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
我感觉这与服务器上安装的 .NET 框架有关。所以昨天我试图创建一个远程桌面连接。然而,这导致发布失败,并出现错误,说明它不受支持或其他内容。我没有抄下来。今天我再次尝试,无论出于何种原因,我都能够获得 RD 连接。不确定是什么问题或发生了什么变化。
服务器是 Windows Server 2012,没有安装 .NET 4.6 的选项,只有 4.5 已安装。所以我更改了错误页面提示的行,使编译行的 targetFramework
为 4.5 而不是 4.6 并再次发布。我这样做是因为我无法更改服务器属性页面中的框架:
现在我收到以下错误消息:
完整的堆栈跟踪是:
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
Microsoft.LightSwitch.BaseServices.Logging.Utilities.HostEnvironment.RunningInAzureCore() +0
Microsoft.LightSwitch.BaseServices.Logging.Utilities.HostEnvironment.RunningInAzure() +121
Microsoft.LightSwitch.BaseServices.Configuration.Utilities.ServerSettings.TryGetSetting(String settingName, Boolean availableInAzureConfig, T& value) +21
Microsoft.LightSwitch.BaseServices.Configuration.Utilities.SettingsManager.GetSettingOrDefault(String settingName, TryGetSettingsDelegate`1 tryGetSettingsFunc, Func`1 getDefaultValue) +37
Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.Init(HttpApplication application) +25
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +618
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712
我终于能够解决服务器上的所有安全问题并安装 .NET 4.6。这让我通过了 'Configuration Error',但给我留下了 'Could not load' 错误。
此错误声称项目正在寻找 Microsoft.WindowsAzure.ServiceRuntime Version 2.8.0.0
。查看我的服务器,是运行Version 2.7.1198.738
。这就是导致它找不到正确版本的原因。
但是我觉得奇怪的是,在我的项目中我只有Microsoft.WindowsAzure.ServiceRuntime.dll Version 2.1.1196.512
。尽管它不在我的任何参考文献中。如果我尝试将其添加为参考,我只能访问版本 2.7.0.0。我也不确定如何在项目中更改它。 grep
在我的项目中使用它只会提取二进制文件,所以我不知道如何更改那里的版本。
然后我下载了 Web 平台安装程序并安装了 Azure SDK 2.8.1,我认为它也在该服务器上安装了 Visual Studio。不知道如何从这个东西中卸载程序,但无论如何。不幸的是,该模块仍然报告为版本 2.7.1196.512 并且尝试访问该网站时出现相同的错误。
不太确定从这里到哪里去。我需要更新服务器上的模块或更改项目中的目标。我也不知道该怎么做,而且找不到资源。
文件 ./ProjectName/Bin/Debug/app.publish/web.config
包含以下几行:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="2.1.0.0" newVersion="2.8.0.0" />
</dependentAssembly>
这显然是在发布时生成的。我的项目中的Web.config
,我可以编辑的Web.config
,没有提到Microsoft.WindowsAzure.ServiceRuntime
。我在网上看到一些地方说我应该添加一个并更改版本号以适用。所以我添加了以下内容:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="2.7.0.0" newVersion="2.7.0.0" />
</dependentAssembly>
因为我的服务器显然没有版本 2.1.0.0 或 2.8.0.0,但有版本 2.7.1196.512。但是,当我发布时,生成的 web.config
仍然具有相同的版本号,并且当我尝试访问它时仍然遇到相同的错误。
如何更改此引用的版本?
根据 MSDN 论坛上 MS 员工的建议,我将 Web.config 更改为以下内容:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0" />
</dependentAssembly>
我已经更新了上面的 无法加载文件或程序集 错误的图片。但这里是堆栈跟踪的相关部分:
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
所以现在它正在寻找两个不同的版本,但都找不到。正确的版本似乎是 2.7.0.0。这就是它在引用 dll 的属性 window 中所说的。 Copy Local也被确认设置为True。
bin
文件夹和 C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.8\bin\runtimes\base
中的 dll 文件的完整版本在我的本地机器和我的服务器上都是 2.7.1198.738。
原来微软从 Azure SDK 中删除了将 Lightswitch 应用程序发布到 Azure 云服务的功能,没有通知任何人,也没有将其放入 Microsoft Office 开发人员工具中(a.k.a .Lightswitch SDK),正如他们计划的那样。
解决方案是部署为 Web 应用程序而不是云服务。