locked
Problem with extensions in VS2012 sp2 RRS feed

  • Question

  • I've created a simple LightSwitch poject that includes both a DesktopClient and an HtmlClient. 

    I can add the DevExpress and Pixata extensions and use them on DesktopClient forms successfully.

    If I rebuild the project the project I get the following error and the project quits running:

    Error 1 The "LSResourceGeneratorsTask" task failed unexpectedly.
    Microsoft.LightSwitch.BaseServices.InternalException: Model loading failed. Cannot cast the underlying exported value of type 'DevExpress.Xpf.LightSwitch.Common.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 'DevExpress.Xpf.LightSwitch.Common.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 RbdmsEnvHtml.HTMLClient

    Is there a solution to this problem?

    Monday, April 22, 2013 1:11 PM

Answers

  • Not sure about DevExpress extension but if you had LS2011 installed as in my case, then the error was present with all old extensions. Garth seems to have the same problem as posted in this Thread with a possible solution.

    There is still no conf from MS but it worked here.

    • Marked as answer by MelroseTom Monday, April 22, 2013 8:45 PM
    Monday, April 22, 2013 7:17 PM

All replies

  • Not sure about DevExpress extension but if you had LS2011 installed as in my case, then the error was present with all old extensions. Garth seems to have the same problem as posted in this Thread with a possible solution.

    There is still no conf from MS but it worked here.

    • Marked as answer by MelroseTom Monday, April 22, 2013 8:45 PM
    Monday, April 22, 2013 7:17 PM
  • I thought I had tried this but I hadn't run the gacutil /u as administrator. When I tried it again while running in the administrator role the gacutil /u was successful and it solved the problem.

    I had this problem on two computers that both had LS 2011 installed. 

    Thanks

    Monday, April 22, 2013 8:48 PM
  • glad to hear that it solved your problem. Maybe MS can verify why LSResourceGeneratorsTask is using the old V1 Microsoft.Lightswitch assembly instead of the V3 one.
    Tuesday, April 23, 2013 7:08 AM
  • This is verified. LightSwitch 2011 (v1) installs Microsoft.LightSwitch into the GAC.  Older extensions may end up referencing that specific version. When we build for a newer project version(v3 with HTML Client), the MSBuild process takes place out of process, the extension gets loaded and the CLR will bind to the Microsoft.LightSwitch.dll(v1) assembly in the GAC, causing the build to fail. 

    mf_falkao has pointed out the workaround.  However, I would like to add that in order to keep everything working for LS2011, you should copy the v1 Microsoft.LightSwitch.dll into the IDE directory for VS 2010.

    Here are the workaround steps:

    1.       Run this command from an elevated Command Prompt:
    c:\Windows\assembly\GAC_MSIL\Microsoft.LightSwitch\10.0.0.0__31bf3856ad364e35>copy Microsoft.LightSwitch.dll "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
    1 file(s) copied.

    2.       Launch Regedit and remove this key:

    "Microsoft.LightSwitch,version=\"10.0.0.0\",publicKeyToken=\"31bf3856ad364e35\",processorArchitecture=\"MSIL\",fileVersion=\"10.0.40219.220\",culture=\"neutral\"<snipped>

    From:

    \HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Assemblies\Global

    3.       Launch a Dev Command Prompt and issue a: gacutil /u Microsoft.LightSwitch

    4.       Launch your solution and compiled.  You shouldn't experience the error MSB4018: The "LSResourceGeneratorsTask" task failed unexpectedly.

    That should resolve the problem.

    Thanks,

    Tim Atkins

    Thursday, May 2, 2013 11:56 PM