Petapoco tt文件错误

时间:2018-01-09 07:41:49

标签: c# .net asp.net-mvc asp.net-mvc-3 petapoco

尝试在petapoco中保存tt文件时出现此错误。我已经在类库中安装了来自nuget包管理器的petapoco,但它没有按预期创建Auto generated Models文件夹。因此,为了解决这个问题,我从我的旧项目中复制了models文件夹,并将其放在类库中,并在App.config文件中指定了我的连接字符串配置。并给出了正确的连接字符串名称和名称空间值。但我仍然面临这个错误。

Severity    Code    Description Project File    Line    Suppression State
Error       Running transformation: System.Runtime.Serialization.SerializationException: Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in Assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=15.0.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.<GetSerializableMembers>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._DTE.get_ActiveSolutionProjects()
   at Microsoft.VisualStudio.TextTemplating0DC162F56BA57DF4829DC8F54798CB1DA7D993D6DA58B9167EA329560E9EF6B318CB739601F4F4361C2EBFFAFDC63B9299812AAACEED30548AB7769327D785AF.GeneratedTextTransformation.GetCurrentProject()
   at Microsoft.VisualStudio.TextTemplating0DC162F56BA57DF4829DC8F54798CB1DA7D993D6DA58B9167EA329560E9EF6B318CB739601F4F4361C2EBFFAFDC63B9299812AAACEED30548AB7769327D785AF.GeneratedTextTransformation.GetConnectionString(String& connectionStringName, String& providerName)
   at Microsoft.VisualStudio.TextTemplating0DC162F56BA57DF4829DC8F54798CB1DA7D993D6DA58B9167EA329560E9EF6B318CB739601F4F4361C2EBFFAFDC63B9299812AAACEED30548AB7769327D785AF.GeneratedTextTransformation.InitConnectionString()
   at Microsoft.VisualStudio.TextTemplating0DC162F56BA57DF4829DC8F54798CB1DA7D993D6DA58B9167EA329560E9EF6B318CB739601F4F4361C2EBFFAFDC63B9299812AAACEED30548AB7769327D785AF.GeneratedTextTransformation.LoadTables()
   at Microsoft.VisualStudio.TextTemplating0DC162F56BA57DF4829DC8F54798CB1DA7D993D6DA58B9167EA329560E9EF6B318CB739601F4F4361C2EBFFAFDC63B9299812AAACEED30548AB7769327D785AF.GeneratedTextTransformation.TransformText() SeigAppV1.Services  D:\Projects\SeigAppV1\SeigAppV1.Services\Models\Generated\Database.tt   1   

1 个答案:

答案 0 :(得分:3)

我遇到了来自Dapper.SimpleCrud的文本模板的相同问题,并且还在寻找VS 2017版本15.5的解决方案,尽管VS 2017预览15.5没有问题(引用了Microsoft.CodeDom.Providers.DotNetCompilerPlatform)。

同时,希望下面的解决方法可以让你继续前进:

  

右键单击.tt文件,然后单击&#34;调试T4模板&#34;