locked
HTML5 Client Errors: ' "LSResourceGeneratorsTask" task failed unexpectedly'; problem with extensions RRS feed

  • Question

  • SADLY MY SOLUTION WAS SHORT-LIVED -- every time I make any change to the application I need to unload & reload my extensions before I can debug. My desktop Client needs OfficeIntegrationManager, so right now for in order to develop the complementary HTML5 Client I need to disable the extension AND REM-out my code in the desktop Client in order to debug the HTML client...This can't be right...?


    I have since found a solution to this problem, but it took me quite a while, and I think it may indicate a bug, so I'm posting the problem in full here and then will post the solution on the same thread.

     

    Nothing quite like this has been posted so far on the forum, and I have NOT upgraded from Preview 2.

    Error details are at the bottom of this post as they are verbose.

     

     

    PROBLEM

    I have successfully built a LightSwitch desktop app in VS 2012 (Professional) -- this solution debugs fine.

     

    I upgraded VS 2012 (Upgrade 2) & migrated this solution and added an HTML Client.

     

    After adding an HTML5 client (and home screen) VS throws a "task failed unexpectedly" error (full details below).

     

    NOTE: If I remove the HTML5 Client from the project, the solution debugs fine again. (I notice the HTML5 Client is removed from the project but not from the source directorie(s))

     

    I created a brand new HTML5 LS project in VS 2012, and a very similar error is thrown, (see below). I notice that the error references an extension that is specific to the desktop/web client, not the HTML5 client.

     

    For both of these projects, when trying to debug again in the same session (having made no changes to the project) the same "JsonModelGenerator" error is thrown (see below).

     

    In a vain hope that somehow my application cache was to blame, I deleted the folders:

    %localappdata%\Microsoft\MSBuild\VSLS\11.3

    %localappdata%\Microsoft\VisualStudio\11.3

    But this has made no change to the behaviour.

     

     

    BACKGROUND

    Windows 7 Home Premium SP1 64-bit

    Visual Studio 2012 Professional installed 28/2/13

    Visual Studio Update 2 installed 5/4/13

    NEVER INSTALLED:

    Microsoft LightSwitch HTML Client Preview 2 for Visual Studio 2012.

    Windows Azure Tools for LightSwitch HTML Client Preview 2 for Visual Studio 2012 – June 2012 SP1.

    Visual Studio 2012 Extensions & Updates Manager indicates no updates required

     

    LightSwitch Desktop app has 2 tables, 6 queries on one table, 4 screens. User Code: some LINQ code on the queries,  tables include computed properties (C#), and there is some C# code on the screens.

     

    HTML5 only app has 1 table, no queries, and 1 browse screen. There is no additional user code.

     

    I have the Migration Log for the desktop app if that would help.

     

     

    ERROR DETAILS

    Task failed unexpectedly Error thrown by sln with desktop & HTML5 Clients:

    Error        1        The "LSResourceGeneratorsTask" task failed unexpectedly.

    Microsoft.LightSwitch.BaseServices.InternalException: Model loading failed. Cannot cast the underlying exported value of type 'OfficeIntegration.ModuleLoader (ContractName="Microsoft.LightSwitch.Model.IModuleDefinitionLoader")' to type 'Microsoft.LightSwitch.Model.IModuleDefinitionLoader'. ---> System.ComponentModel.Composition.CompositionContractMismatchException: Cannot cast the underlying exported value of type 'OfficeIntegration.ModuleLoader (ContractName="Microsoft.LightSwitch.Model.IModuleDefinitionLoader")' to type 'Microsoft.LightSwitch.Model.IModuleDefinitionLoader'.

       at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)

       at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)

       at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()

       at System.Lazy`1.CreateValue()

       at System.Lazy`1.LazyInitValue()

       at System.Lazy`1.get_Value()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.<get_ModuleLoaderExports>b__9(Lazy`2 ex)

       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.get_ModuleLoaderExports()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.LoadItems()

       --- End of inner exception stack trace ---

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.LoadItems()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.get_Modules()

       at Microsoft.LightSwitch.Model.Extensions.Internal.ModelUtilities2.GetClientModule(IModelService modelService)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.LsmlJsonConverter.GetClientModule(ProjectIdentifier pid)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.LsmlJsonConverter..ctor(ProjectIdentifier pid)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.JsonModelGenerator.GenerateArtifact()

       at Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorBase.Generate()

       at Microsoft.LightSwitch.CodeGenerator.Implementation.CustomResultCodeGenerator.Microsoft.LightSwitch.CodeGenerator.ICodeGenerator.Generate(ProjectIdentifier pid, IDictionary`2 parameters)

       at Microsoft.LightSwitch.CodeEditing.Implementation.CodeGeneratorService.RunGeneratorsImmediately(TbdCodeGeneratorType generatorType, String LightSwitchProjectType, String lightSwitchProjectSubType, String projectDirectory, IDictionary`2 parameters, IList`1 generatedFiles, IList`1& issues)

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.RunGeneratorsInNonIdeScenario()

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.Execute()

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSResourceGeneratorsTask.Execute()

       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()        C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets        208        5        EKS_WalkingLog.HTMLClient

     

    JsonModelGenerator Error thrown by sln with desktop & HTML5 Clients:

    Error        1        JsonModelGenerator - Object reference not set to an instance of an object.        C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets        208        5        EKS_WalkingLog.HTMLClient

     

     

    Task failed unexpectedly Error thrown by sln with HTML5 Client only:

    Error        1        The "LSResourceGeneratorsTask" task failed unexpectedly.

    Microsoft.LightSwitch.BaseServices.InternalException: Model loading failed. Cannot cast the underlying exported value of type 'MetroThemeExtension.Metadata.ModuleLoader (ContractName="Microsoft.LightSwitch.Model.IModuleDefinitionLoader")' to type 'Microsoft.LightSwitch.Model.IModuleDefinitionLoader'. ---> System.ComponentModel.Composition.CompositionContractMismatchException: Cannot cast the underlying exported value of type 'MetroThemeExtension.Metadata.ModuleLoader (ContractName="Microsoft.LightSwitch.Model.IModuleDefinitionLoader")' to type 'Microsoft.LightSwitch.Model.IModuleDefinitionLoader'.

       at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)

       at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)

       at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()

       at System.Lazy`1.CreateValue()

       at System.Lazy`1.LazyInitValue()

       at System.Lazy`1.get_Value()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.<get_ModuleLoaderExports>b__9(Lazy`2 ex)

       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.get_ModuleLoaderExports()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.LoadItems()

       --- End of inner exception stack trace ---

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.LoadItems()

       at Microsoft.LightSwitch.Model.Implementation.ModelServiceBase.get_Modules()

       at Microsoft.LightSwitch.Model.Extensions.Internal.ModelUtilities2.GetClientModule(IModelService modelService)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.LsmlJsonConverter.GetClientModule(ProjectIdentifier pid)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.LsmlJsonConverter..ctor(ProjectIdentifier pid)

       at Microsoft.LightSwitch.CodeGenerator.Implementation.MobileWeb.JsonModelGenerator.GenerateArtifact()

       at Microsoft.LightSwitch.CodeGenerator.Implementation.CodeGeneratorBase.Generate()

       at Microsoft.LightSwitch.CodeGenerator.Implementation.CustomResultCodeGenerator.Microsoft.LightSwitch.CodeGenerator.ICodeGenerator.Generate(ProjectIdentifier pid, IDictionary`2 parameters)

       at Microsoft.LightSwitch.CodeEditing.Implementation.CodeGeneratorService.RunGeneratorsImmediately(TbdCodeGeneratorType generatorType, String LightSwitchProjectType, String lightSwitchProjectSubType, String projectDirectory, IDictionary`2 parameters, IList`1 generatedFiles, IList`1& issues)

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.RunGeneratorsInNonIdeScenario()

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSGeneratorsTask.Execute()

       at Microsoft.LightSwitch.BuildTasks.CodeGen.LSResourceGeneratorsTask.Execute()

       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()        C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets        208        5        EKS_WalkingLogHTML.HTMLClient

     

     

    JsonModelGenerator Errorthrown by sln with HTML5 Client only:

    Error        1        JsonModelGenerator - Object reference not set to an instance of an object.        C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v3.0\Microsoft.LightSwitch.Build.Tasks.targets        208        5        EKS_WalkingLogHTML.HTMLClient

     



    • Edited by EKlarSolutions Wednesday, April 10, 2013 7:26 PM further explanation of continuing problem
    Wednesday, April 10, 2013 3:33 PM

All replies

  • I have identified that this appears to be a problem with the extensions being loaded automatically for new projects, AND also affects projects with extensions enabled if you want to edit the project, see previous post.

     

    SOLUTION immediate: 

    Disable ALL extensions (except the native MS LS Extensions) from the solution

    Restart VS

    REbuild solution

    Re-enable required solutions

    REbuild solution

    Debug now works fine

    NB if you have a desktop/web LS client you may need to change the shell &/or theme

     

    SOLUTION med-term:

    Don't automatically include any but the native extension in new projects, and enable them on a need-to-use basis only

     

    SOLUTION long term:

    This looks like a bug to me ;-)

    but I'm happy to be educated if I'm wrong...

     

     

    NOTE: I have replicated this problem and solution a couple of times.

     

    PS I suspect the  "JsonModelGenerator" error is to do with VS being unable to generate required code in the previous build/run, so is an indirect result of the original problem


    Wednesday, April 10, 2013 3:35 PM
  • Any fix for this?  I sadly am having the same issue in a project using ComponentOne's extensions.

    Thanks,

    Eric

    Thursday, October 31, 2013 3:23 PM