Error installing NuGet package

Apr 19, 2012 at 2:57 PM


I just tried installing T4MVC package from NuGet (2.8.1) on a MVC4 project and got this error, just after the installation says "Successfully installed":

Error 2 Running transformation: System.Runtime.Serialization.SerializationException: Type 'Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase' in Assembly 'Microsoft.VisualStudio.Platform.WindowManagement, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
Server stack trace:    at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)   at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage..ctor(IMethodReturnMessage mrm)   at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.SmuggleIfPossible(IMessage msg)   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)
Exception rethrown at [0]:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)   at EnvDTE.ProjectItem.Open(String ViewKind)   at Microsoft.VisualStudio.TextTemplating4A4267BEEF0C92625588A275EF198455.GeneratedTextTransformation.GetProjectContainingT4File(DTE dte) in x:\Cuéntame\Aplicación\Oikos\Oikos.WebUI\ 674   at Microsoft.VisualStudio.TextTemplating4A4267BEEF0C92625588A275EF198455.GeneratedTextTransformation.PrepareDataToRender(TextTransformation tt) in x:\Cuéntame\Aplicación\Oikos\Oikos.WebUI\ 654   at Microsoft.VisualStudio.TextTemplating4A4267BEEF0C92625588A275EF198455.GeneratedTextTransformation.TransformText() in x:\Cuéntame\Aplicación\Oikos\Oikos.WebUI\ 559   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result) 1 1

Anyway I Just went on to try if it was working but it's not.

Thanks in advance for any help!


Apr 19, 2012 at 3:59 PM

Strange. What happens if you:

  • Open
  • Right click it in Solution Explorer and choose Run Custom Tool
Apr 19, 2012 at 4:01 PM

Also, what Add-Ins do you have installed in VS? I think there was one that was causing T4MVC issues, but I can't instantly recall which.

Apr 19, 2012 at 4:43 PM


Running custom tool on worked and it created the "generated" controllers, thanks.

I have no Add-In installed.

Afther that I added a link in the _layout.chtml, just to check if it was working as I understand it should and this line:

<li>@Html.ActionLink("Personas", Oikos.WebUI.Controllers.PersonaController.Index</li>

gets the squiggly line under the action name, but the one that seems to be ok (without the squiggly line) is:

<li>@Html.ActionLink("Personas", Oikos.WebUI.Controllers.PersonaController.ActionNameConstants.Index</li>

I understand it should work as the first line, Am I wrong or missing something?



Apr 19, 2012 at 5:25 PM

No, that is not the correct way to do this in T4MVC. See section 2.2 in the doc for examples.

Though if you really want to do it using the action name, you can use MVC.Personna.ActionNames.Index, but that is not recommended in this scenario is you'd miss out on most of the power of T4MVC.

Apr 19, 2012 at 7:07 PM

I'm sorry, I don't understand.

If I use PersonaController.Index(), as I understand I have to do since it doesn't receive any parameter, according to the doc, I get the squiggly line.

Can you point me to a Sample app that uses T4MVC ActionLinks from the _layout.cshtml?

Apr 19, 2012 at 7:48 PM

Here is a small sample I just put together:

Apr 20, 2012 at 12:40 AM

Hey man you rock!

Thanks a lot for the sample!

When I checked the _Layout page I realized I didn't pay attention to the naming and thought I had to reference the original Controller.Action, it wasn't clear for me, from what I read in the documentation, that I had to reference the new generated "MVC" class.

It now works ok.

Best regards,

Miguel Veloso.

Feb 28, 2013 at 2:30 PM
Edited Feb 28, 2013 at 2:31 PM
For reference I've experienced the same issue as this poster.
I've also ran the custom tool and that seems to have resolved the problem.
Using Visual Studio Express 2012

Feb 28, 2013 at 7:09 PM
Yeah, that's a weird issue. I think I've seen it once or twice as well, but I can't explain it. T4MVC calls EnvDTE.ProjectItem.Open() and somehow that blows up.

My guess is that during project creation, the API may not be fully ready until creation is complete, and there is some kind of race condition.
May 8, 2013 at 10:57 PM
I'm hitting this issue as well, driving me up the wall.
May 8, 2013 at 11:00 PM
If it's the same issue as others, it only happens at the time you install the package, and everything is fine afterwards.