This project is read-only.

Errors when deploying to Azure websites

Mar 31, 2014 at 10:43 PM
Edited Mar 31, 2014 at 11:21 PM
I'm having errors when trying to deploy to Windows Azure.
  • Windows 7 Ultimate
  • Visual Studio 2013
  • ASP.NET MVC 5
Building locally is fine.

The error is pasted below. Any ideas?

Error 1 Running transformation: System.InvalidOperationException: The snapshot is out of date and can not be used anymore because the type tree has been updated. A new snapshot needs to be acquired.
at Microsoft.RestrictedUsage.CSharp.Semantics.DefinitionsInterop.TypeDefinition_GetMemberCount(Handle treeHandle, Int32 assemblyId, IntPtr typeId, Int32& count)
at Microsoft.RestrictedUsage.CSharp.Semantics.TypeDefinitionInfo.get_MemberDefinitions()
at Microsoft.RestrictedUsage.CSharp.Semantics.TypeDefinitionInfoWithCache.get_MemberDefinitions()
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.GetMemberForDeclaration(ParseTreeNode declaration)
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.GetMemberForMethodDeclaration(MethodBaseNode methodDeclaration)
at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.GetMemberFromMemberDeclaration(Compilation compilation, MethodBaseNode node)
at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.GetMemberFromMemberDeclaration(Compilation compilation, ParseTreeNode node)
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeFunction.get_Type()
at EnvDTE80.CodeFunction2.get_Type()
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessControllerActionMethods(ControllerInfo controllerInfo, CodeClass2 current) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 824
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessControllerType(CodeClass2 type, AreaInfo area, DateTime controllerLastWriteTime) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 726
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessControllersRecursive(ProjectItem projectItem, AreaInfo area) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 658
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessControllersRecursive(ProjectItem projectItem, AreaInfo area) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 643
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessAreaControllers(ProjectItems areaFolderItems, AreaInfo area, ProjectItem areaFolder) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 613
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessArea(ProjectItems areaFolderItems, ProjectItem areaFolder) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 591
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ProcessAreas(Project project) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 556
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.PrepareDataToRender(TextTransformation tt) in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 537
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.TransformText() in c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt:line 40 c:\Users\King Wilder\Source\Workspaces\GolfTour\GolfTour\GolfTour.Mvc\T4MVC.tt 824 1 GolfTour.Mvc

Thanks,

King Wilder
Mar 31, 2014 at 11:05 PM
Never seen this error. But deploying should not normally cause the template to get generated. Questions:
  1. Does this happen consistently, even across VS restarts?
  2. When you get this, do you get the same error if you just right click t4mvc.tt and ask it to regen?
May 20, 2014 at 6:00 PM
Edited May 20, 2014 at 6:12 PM
I am seeing this error when deploying to a remote website, NOT azure. I have published to this site before without incident, not sure what is different this time.

To answer your questions, yes it happens consistently across VS restarts, whether or not I run it as administrator. I do NOT get the same error when I click "Run custom tool" for T4MVC.tt, that seems to work as it should. However...

When this fails to publish I get hundreds of errors showing up. 794 errors in 22 files, to be exact. I run the custom tool on T4MVC.tt and the errors go away, then when I try to publish I get the error message above and the errors reappear. I am running Resharper along with all this, so the errors are all from Resharper's engine.

Very frustrating, I'm hoping you can help, thanks!
Dave
May 20, 2014 at 6:35 PM
I see references to that error here. Which t4mvc line and which version do you have? Maybe that'll give clues about what's going on.

As a test, can you try disabling resharper to see if it's related to that? In the end, T4MVC is just calling the VS code model API.
May 20, 2014 at 7:32 PM
I am running T4MVC version 3.9.0 as well as teh T4MVCExtensions package. I also have T4Scaffolding installed, version 1.0.8.

I am running VS2013 on Windows 7 Pro, using .NET 4.0 -- we still have to target XP machines, ugh...

Here is the exact text of the exception, looks like it is thrown at line 1706 with Resharper suspended. It gets thrown at line 828 with Resharper enabled. Odd?

Error 44 Running transformation: System.InvalidOperationException: The snapshot is out of date and can not be used anymore because the type tree has been updated. A new snapshot needs to be acquired.
at Microsoft.RestrictedUsage.CSharp.Semantics.DefinitionsInterop.TypeDefinition_GetMemberCount(Handle treeHandle, Int32 assemblyId, IntPtr typeId, Int32& count)
at Microsoft.RestrictedUsage.CSharp.Semantics.TypeDefinitionInfo.get_MemberDefinitions()
at Microsoft.RestrictedUsage.CSharp.Semantics.TypeDefinitionInfoWithCache.get_MemberDefinitions()
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.GetMemberForDeclaration(ParseTreeNode declaration)
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.GetMemberForMethodDeclaration(MethodBaseNode methodDeclaration)
at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.GetMemberFromMemberDeclaration(Compilation compilation, MethodBaseNode node)
at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.GetMemberFromMemberDeclaration(Compilation compilation, ParseTreeNode node)
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeFunction.get_Type()
at EnvDTE80.CodeFunction2.get_Type()
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.FunctionInfo.get_ReturnTypeImpl() in c:\dev_data\ProductionProjects\all-spark\WebReporter\T4MVC.tt:line 1706
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.ActionMethodInfo.get_ReturnTypeImpl() in c:\dev_data\ProductionProjects\all-spark\WebReporter\T4MVC.tt:line 1807
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.FunctionInfo.get_ReturnTypeFullName() in c:\dev_data\ProductionProjects\all-spark\WebReporter\T4MVC.tt:line 1710
at Microsoft.VisualStudio.TextTemplating07D0D4760165F129D614BBB18D2FAC8D8EEC2621276B7FB4994B04BEAF126D48DAE40CE949BD8B9980C5FC24473980900CC7A42CE0E2356630EA75EF83BD33AA.GeneratedTextTransformation.TransformText() in c:\dev_data\ProductionProjects\all-spark\WebReporter\T4MVC.tt:line 361 c:\dev_data\ProductionProjects\all-spark\WebReporter\T4MVC.tt 1706 1 WebReporter
May 20, 2014 at 7:41 PM
In both cases, the failure happens when calling CodeFunction2.Type, so at least there is some consistency there. Basically, it's trying to get the return type of one of the action methods.

Presumably, we could repro this by writing a minimal t4 template that just makes this call. It may be interesting to figure out whether this happens for all action methods, or whether there is some specific one that's throwing it off. You should be able to debug it by attaching another instance of VS to the VS that has your project opened, and then setting breakpoints in t4mvc.tt (from the debuggER VS, not debuggEE).
May 20, 2014 at 8:37 PM
I will look into this tomorrow, as I have to take off for the day. Will let you know what I find out...
May 21, 2014 at 9:01 PM
Edited May 21, 2014 at 9:04 PM
More info, although I don't know how much it will tell you that you don't already know. Most of the errors I get once it fails are "The type or namespace name 'T4MVC_System_Web_Mvc_ActionResult' could not be found (are you missing using directive or an assembly reference?)" and the same error with 'Dummy' as the name not found. When I regen T4MVC.tt the errors go away, until I try to publish again.

Also, I am having no luck setting breakpoints in T4MVC.tt - message says "The breakpoint will not currently be hit. No symbols have been loaded for this document."

So how do I set a breakpoint if I don't have the symbols file?

I have updated T4MVC to version 3.9.1 and installed the R2 patch for VS2013 with no change in behavior. The line number changed (850 now instead of 828) but that's the only difference I can see.

Thanks for any assistance,
Dave
May 21, 2014 at 9:37 PM
It would be ideal if I was able to repro this myself. If you use t4mvc on a clean new MVC app, do you also see this?
  • If yes, then it's probably something that depends on some state of the machine, such that some people see it and others don't
  • If no, then maybe for a given project, it would repro on every machine
If it's the latter and I can get a repro site, I'd be happy to investigate.

In order to set BPs, you may need to run the T4MVC custom tool once, so it gets built and loaded.
May 21, 2014 at 11:07 PM
I just proved this project loads and publishes just fine on another developer's machine so it's just my instance that's broken. I am going to attempt to figure out how to get it working again, will ping you if I need some inside information on how things work. Otherwise I'll just update this thread when I get it working again.
May 21, 2014 at 11:48 PM
Ok, thanks for following up. Would be nice to get to the bottom of it!
Jun 3, 2014 at 6:35 PM
It appears that this error occurs when you have the AutoT4MVC extension enabled. Simply disabling it fixed the issue for me.
Jun 3, 2014 at 7:05 PM
I see. It might be worth reporting the issue on https://github.com/bennor/AutoT4MVC.
Jun 24, 2014 at 10:33 PM
I finally got this to work for me! There seems to be an error in VS that causes this - see Stack Overflow at http://stackoverflow.com/questions/10118086/whats-the-reason-for-error-message-i-am-using-vs-2010-professional-edition about halfway down the page. There is a comment / answer that starts "This is a bug in Visual Studio." To get things to work for me I followed the directions there - I cleaned the solution, rebuilt the project, shut down VS 2013 and restarted it, then published without editing any code before I tried the publish operation. I also had deleted AutoT4MVC earlier, but that made no difference for me.

This is back in Microsoft's court, waiting for a parser rewrite to get fixed. In the meantime we just mutter under out breath and curse the parsing gods for making our lives a little less enjoyable... :)
Jan 9, 2015 at 11:33 AM
Guys,
I have the same issue time to time in T4MVC.tt and I also using AutoT4MVC:
Running transformation: System.InvalidOperationException: The snapshot is out of date and can not be used anymore because the binder has been updated. A new snapshot needs to be acquired.

This issue is go way if I Unload Project (right click on Project and select Unload Project) where I have this issue and then Reload Project., after that I can re-run T4MVC without any issues. So you do not need to restart VS etc., just unload and reload the project where T4MVC script is located.

I hope that this workaround will be useful for someone.

P.S. David thanks a lot for T4MVC.