0

I have an app hosted on Azure that was built with the Lightswitch Silverlight client. I recently went to update this and replace it with an HTML based client. But I received the following error after the publish to Azure succeeded and I tried to access the site:

Runtime error

I tried to open the old Silverlight project but I've since upgrade to Visual Studio 2015 and so it wants to upgrade the project. That failed miserably. After much manual tinkering I was able to publish that as well but receive the same error message when I tried to access it. I've enabled verbose tracing but attempting to access the trace results in the same error.

I've had issues publishing before (example 1, example 2). But none of those tricks seem to work this time. I wouldn't really expect them to since the error is completely different.

I finally took the error messages advice and added the customErrors line. That resulted in the following webpage:

Configuration error

The last line that didn't wrap was as follows:

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.

I had a feeling it had to do with the .NET framework installed on the server. So yesterday I had tried to create a remote desktop connection. However that resulted in a failed publish and an error saying something about it not being supported or something. I didn't copy it down. Today I tried again and was able to get an RD connection for whatever reason. Not sure what the problem was or what changed.

The server is Windows Server 2012 and there is no option to install .NET 4.6, only 4.5 which is already installed. So I changed the line hinted at by the error page so that the targetFramework of the compilation line was 4.5 instead of 4.6 and published again. I did this because I can't change the framework in the Server properties page:

Server properties

Now I get the following error message:

Could not load file or assembly

The full stack trace is:

[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

I was finally able to work through all the security on the server and install .NET 4.6. This got me past the 'Configuration Error' but left me with the 'Could not load' error.

This error claims that the project is looking for Microsoft.WindowsAzure.ServiceRuntime Version 2.8.0.0. Looking at my server, it is running Version 2.7.1198.738. So this is what is causing it as it can't find the correct version.

But what I find strange is that in my project I only have Microsoft.WindowsAzure.ServiceRuntime.dll Version 2.1.1196.512. Though it isn't in any of my references. If I try to add it as a reference, I only have access to Version 2.7.0.0. I'm not sure how to change this in the project either. greping for it in my project only pulls up binary files so I have no idea how to change the version there.

I then downloaded the Web Platform Installer and Installed the Azure SDK 2.8.1 which, I think, also installed Visual Studio on this server. Not sure how to uninstall programs from this thing but whatever. Unfortunately the module still reports as Version 2.7.1196.512 and trying to access the website give the same error.

Not really sure where to go from here. I either need to update the modules on the server or change the targets in my project. I don't know how to do either and am having trouble finding resources.


The file ./ProjectName/Bin/Debug/app.publish/web.config has the following lines:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="2.1.0.0" newVersion="2.8.0.0" />
  </dependentAssembly>

That is clearly generated upon publish. The Web.config that is in my project, the one that I can edit, has no mention of Microsoft.WindowsAzure.ServiceRuntime. I saw a few places around the web that said that I should add one and change the version numbers to be applicable. So I added the following:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="2.7.0.0" newVersion="2.7.0.0" />
  </dependentAssembly>

Since my server apparently does not have either versions 2.1.0.0 or 2.8.0.0 but does have version 2.7.1196.512. However, when I publish, the generated web.config still has the same version numbers and I still get the same error when I try to access it.

How do I change the version of this reference?


On the advice of a MS employee on the MSDN forums, I changed my Web.config to have the following:

  <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>

I've updated the picture above of the Could not load file or assembly error. But here is the pertinent section of the stack trace:

[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)]

So now it's looking for two different versions and can find neither. The correct version seems to be 2.7.0.0. This is what it says in the properties window of the reference dll. Copy Local is also confirmed to be set to True.

The full version of the dll file in the bin folder and in C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.8\bin\runtimes\base on both my local machine and on my server are all 2.7.1198.738.

embedded.kyle
  • 10,976
  • 5
  • 37
  • 56
  • Crossposted from MSDN because I wasn't getting any traction there: https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3f0207c-851c-4b0c-bb59-a061b404f761/cant-publish-lightswitch-html-client?forum=windowsazuredevelopment – embedded.kyle Jan 15 '16 at 18:42
  • Is Microsoft.WindowsAzure.ServiceRuntime a nuget package? You typically need to reinstall all nuget packages after changing the target framework. https://docs.nuget.org/consume/reinstalling-packages – jrummell Jan 15 '16 at 21:25
  • @jrummell I've changed the target framework back to 4.6 as that did not seem to be the problem and I've also updated the server to have .NET 4.6. The only thing in NuGet is **Unofficial**.Microsoft.WindowsAzure.ServiceRuntime. I think the official is from the Web Platform Installer and the Azure SDK. – embedded.kyle Jan 15 '16 at 21:29

1 Answers1

0

Turns out Microsoft removed the ability to publish a Lightswitch app to an Azure Cloud Service from the Azure SDK, didn't notify anyone, and didn't put it in the Microsoft Office Developer Tools (a.k.a. the Lightswitch SDK) as they had planned.

Solution was to deploy as a Web App instead of a Cloud Service.

Discussion thread. Connect bug.

embedded.kyle
  • 10,976
  • 5
  • 37
  • 56