MoonStorm / FastCrud

fast .NET ORM for strongly typed people
MIT License
506 stars 128 forks source link

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. #138

Closed Omzig closed 2 years ago

Omzig commented 5 years ago

There is something wrong with the Config.tt:

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.<>cDisplayClass9_0.b_0(MemberHolder ) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 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.TextTemplatingD903812D6A5ABCC9CC59766E677B800ED7025763DF85FFF07DC76D174CF58E61084BEA14A9983C7C2BEA1FD11E2F11054ED475008B6B5C793B5EDA2914247B64.GeneratedTextTransformation.GetCurrentProject() at Microsoft.VisualStudio.TextTemplatingD903812D6A5ABCC9CC59766E677B800ED7025763DF85FFF07DC76D174CF58E61084BEA14A9983C7C2BEA1FD11E2F11054ED475008B6B5C793B5EDA2914247B64.GeneratedTextTransformation.GetConnectionString(String& connectionStringName, String& providerName) at Microsoft.VisualStudio.TextTemplatingD903812D6A5ABCC9CC59766E677B800ED7025763DF85FFF07DC76D174CF58E61084BEA14A9983C7C2BEA1FD11E2F11054ED475008B6B5C793B5EDA2914247B64.GeneratedTextTransformation.InitConnectionString() at Microsoft.VisualStudio.TextTemplatingD903812D6A5ABCC9CC59766E677B800ED7025763DF85FFF07DC76D174CF58E61084BEA14A9983C7C2BEA1FD11E2F11054ED475008B6B5C793B5EDA2914247B64.GeneratedTextTransformation.LoadTables() at Microsoft.VisualStudio.TextTemplatingD903812D6A5ABCC9CC59766E677B800ED7025763DF85FFF07DC76D174CF58E61084BEA14A9983C7C2BEA1FD11E2F11054ED475008B6B5C793B5EDA2914247B64.GeneratedTextTransformation.TransformText() DataAccess C:\Users\username\Documents\Visual Studio 2017\Projects\Play Room\DapperPOC\DataAccess\Models\TestModelGeneratorConfig.tt 1

Here is the config tt file: <#@ template hostspecific="True" #>

<# / This is a sample configuration file for GenericModelGenerator.tt. When you create your own configuration file, don't forget to set the 'Custom Tool' to TextTemplatingFileGenerator / // Settings ConfigPath = @"TestModels.config"; //Looks in current project for web.config or app.config by default. You can override it to point to a different config file. ConnectionStringName = "EntityGeneration"; // Uses the last connection string in the config if not specified Namespace = "Dapper.FastCrud.Tests.Models"; ClassPrefix = ""; ClassSuffix = ""; IncludeViews = true; IgnoreColumnDefaultValues = true; // when set to false, the generated properties mapped to columns having default values will be refreshed with the database assigned values on insert. ExcludeTablePrefixes = new string[]{"ELMAH", "AspNet_", "HangFire."};

>

<#@ include file="GenericModelGenerator.tt" #> <#+ void ConfigureTableMappings(Tables tables){ / // Tweak Schema tables["tablename"].Ignore = true; // To ignore a table tables["tablename"].ClassName = "newname"; // To change the class name of a table tables["tablename"]["columnname"].Ignore = true; // To ignore a column tables["tablename"]["columnname"].PropertyType="bool"; // To change the property type of a column / }

>

andrewbadera commented 5 years ago

Also seeing this issue.

dstringvc commented 5 years ago

This seems to be a problem with .NET CORE projects only. .NET Framework projects don't have this problem. My work-around in a .NET CORE project is to run the T4 template in debug mode. It's slow, but it completes with no errors.

tanovex commented 5 years ago

I was also seeing this issue in a .NET CORE project. Adding

<#@ import namespace="Microsoft.VisualStudio.TextTemplating" #>
<#
  IServiceProvider serviceProvider = (IServiceProvider)this.Host;
  EnvDTE.DTE dte = (EnvDTE.DTE) serviceProvider.GetCOMService(typeof(EnvDTE.DTE));
 #>

after <#@ assembly name="EnvDTE" #> and replacing the GetService calls with GetCOMService in the GenericModelGenerator.tt file fixed it for me. See GenericModelGenerator.txt

MoonStorm commented 2 years ago

Thanks @tanovex. That is indeed the solution to this little problem.

MoonStorm commented 2 years ago

Fixed in 3.0