vs2017 中 运行 自定义工具时出现 T4 错误
T4 error when running Custom Tool in vs2017
当我想 运行 来自 vs2017 的以下命令 "Run Cosutom Tool" 时,我确实遇到了问题。
VS 更新后它停止工作。
而不是 运行 编译 T4 并生成与此文件相关的所有代码。
输出文件将包含以下错误消息:
Type 'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem'
in Assembly 'Microsoft.VisualStudio.Data.Tools.Package,
Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is
not marked as serializable.
完整错误信息:
Severity Code Description Project File Line Suppression State
Error Running transformation:
System.Runtime.Serialization.SerializationException: Type
'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem' in
Assembly 'Microsoft.VisualStudio.Data.Tools.Package, Version=15.1.0.0,
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.<>c__DisplayClass9_0.b__0(MemberHolder
_) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey
key, Func
2 valueFactory) 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._Solution.FindProjectItem(String
FileName) at
Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.VSManager..ctor(ITextTemplatingEngineHost
host, StringBuilder template) at
Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.Create(ITextTemplatingEngineHost
host, StringBuilder template) at
Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.TransformText() Staging D:\XXXXXXX\MedatadataGeneratedObjects.tt 1
在我的 T4 中,我使用 var dte = (DTE) hostServiceProvider.GetService(typeof(DTE));
我切换到使用 var dte = (DTE) hostServiceProvider.GetCOMService(typeof(DTE));
当我想 运行 来自 vs2017 的以下命令 "Run Cosutom Tool" 时,我确实遇到了问题。
VS 更新后它停止工作。
而不是 运行 编译 T4 并生成与此文件相关的所有代码。 输出文件将包含以下错误消息:
Type 'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem' in Assembly 'Microsoft.VisualStudio.Data.Tools.Package, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
完整错误信息:
Severity Code Description Project File Line Suppression State Error Running transformation: System.Runtime.Serialization.SerializationException: Type 'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem' in Assembly 'Microsoft.VisualStudio.Data.Tools.Package, Version=15.1.0.0, 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.<>c__DisplayClass9_0.b__0(MemberHolder _) at System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key, Func
2 valueFactory) 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._Solution.FindProjectItem(String FileName) at Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.VSManager..ctor(ITextTemplatingEngineHost host, StringBuilder template) at Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.Create(ITextTemplatingEngineHost host, StringBuilder template) at Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.TransformText() Staging D:\XXXXXXX\MedatadataGeneratedObjects.tt 1
在我的 T4 中,我使用 var dte = (DTE) hostServiceProvider.GetService(typeof(DTE));
我切换到使用 var dte = (DTE) hostServiceProvider.GetCOMService(typeof(DTE));