我想从vs2017运行以下命令“运行Cosutom工具”时确实遇到问题。
VS更新后它将停止工作。
代替运行T4并生成与此文件相关的所有代码。 输出文件将包含以下错误消息:
键入“ Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem” 在程序集“ Microsoft.VisualStudio.Data.Tools.Package”中, 版本= 15.1.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'是 没有标记为可序列化。
完整错误消息:
严重性代码描述项目文件行抑制状态 运行转换错误: System.Runtime.Serialization.SerializationException:类型 ``Microsoft.VisualStudio.Data.Tools.Package.Internal.OAFileItem'' 程序集'Microsoft.VisualStudio.Data.Tools.Package,Version = 15.1.0.0, 文化=中性,PublicKeyToken = b03f5f7f11d50a3a'未标记为 可序列化。
服务器堆栈跟踪:位于 System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType 类型) System.Runtime.Serialization.FormatterServices。<> c__DisplayClass9_0.b__0(MemberHolder _)位于System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key, Func
2 valueFactory) System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type 类型,StreamingContext上下文) System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() 在 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj,ISurrogateSelector surrogateSelector,StreamingContext上下文, SerObjectInfoInit serObjectInfoInit,IFormatterConverter转换器, ObjectWriter objectWriter,SerializationBinder活页夹) System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj,ISurrogateSelector surrogateSelector,StreamingContext上下文, SerObjectInfoInit serObjectInfoInit,IFormatterConverter转换器, ObjectWriter objectWriter,SerializationBinder活页夹) System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object 图,Header [] inHeaders,__ BinaryWriter serWriter,布尔值fCheck)
在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(流 serializationStream,对象图,Header []标头,布尔值fCheck)
在 System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize) System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage..ctor(IMethodReturnMessage mrm) System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.SmuggleIfPossible(IMessage 味精) System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte [] reqStmBuff,SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage&smuggledMrm),网址为 System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object [] args)在[0]处抛出异常: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32类型)位于EnvDTE._Solution.FindProjectItem(String FileName)位于 Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.Host.Host 主机,StringBuilder模板)位于 Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.Manager.Create(ITextTemplating 主机,StringBuilder模板)位于 Microsoft.VisualStudio.TextTemplating6FCAD03755FEA2CF76F69000C72CACC8E11DA21396664770DDB2AE835D7A8E82309989CCBC13688F6AC52D362D892E524A6D1554F901D313ED8AA1C0920ED56C.GeneratedTextTransformation.TransformTextX(对象)\ TransformTextX(文本)
答案 0 :(得分:1)
在T4中,我使用的是master = Tk()
class game_of_life_GUI() :
def __init__(self, WIDTH, HEIGHT) :
self.width = WIDTH
self.height = HEIGHT
self.start = (self.width - self.height)/2
def draw(self, w, Map) :
square_length = self.height / len(Map)
for i in range(len(Map)) :
for j in range(len(Map[i])) :
if(Map[i][j] == 0) :
w.create_rectangle(self.start + i*square_length, j*square_length,
self.start + (i+1)*square_length, (j+1)*square_length,
fill = "white", outline = "black")
else :
w.create_rectangle(self.start + i*square_length, j*square_length,
self.start + (i+1)*square_length, (j+1)*square_length,
fill = "black", outline = "black")
w.pack()
def increase_map(Map) :
for i in range(len(Map)) :
Map[i].append(0)
Map[i].append(0)
Map[i][1:-1] = Map[i][0:-2].copy()
Map[i][0] = 0
Map.insert(0, [0]*len(Map[0]))
Map.append([0]*len(Map[0]))
return Map
def next_turn(Map) :
num_y = [-1, 0, 1, -1, 1, -1, 0, 1]
num_x = [1, 1, 1, 0, 0, -1, -1, -1]
flag = 0
new_Map = copy.deepcopy(Map)
for i in range(len(Map)) :
for j in range(len(Map[0])) :
sum = 0
for p in range(8) :
try :
if(Map[i + num_y[p]][j + num_x[p]] == 1) : sum +=1
except Exception as e :
pass
if (Map[i][j] == 1 and (sum == 2 or sum == 3)) :
new_Map[i][j] = 1
if(flag == 0 and (i ==0 or j == 0)) :
flag = 1
elif (Map[i][j] == 0 and sum == 3) :
new_Map[i][j] = 1
if(flag == 0 and (i==0 or j==0)) :
flag = 0
else :
new_Map[i][j] = 0
return (new_Map, flag)
def life_game(Map, num, flag, width, height) :
GUI = game_of_life_GUI(width, height)
w = Canvas(master, width = width, height = height)
for i in range(num) :
if (flag == 1) :
Map = increase_map(Map)
Map, flag = next_turn(Map)
GUI.draw(w, Map)
return Map
def create_random_map(length) :
ls = []
for i in range(length) :
ls.append([])
for j in range(length) :
ls[i].append(rd.randrange(0, 2))
return ls
LENGTH = 5
WIDTH, HEIGHT = (500, 500)
ROTATION = 1
Map = create_random_map(LENGTH)
print(Map)
Game = life_game(Map, ROTATION, flag = 1, width = WIDTH, height = HEIGHT)
,而我改用了var dte = (DTE) hostServiceProvider.GetService(typeof(DTE));