服務端跑起來發現出現了很多警告, 警告內容是註冊消息 OpCode = 0, 警告如下

消息opcode为0: C2S_BomberGame_QueryFrameMessage

接著從錯誤的地方順著流程查看

List<Type> types = Game.EventSystem.GetTypes(typeof(MessageAttribute));
foreach (Type type in types)
{
    object[] attrs = type.GetCustomAttributes(typeof(MessageAttribute), false);
    if (attrs.Length == 0){
         continue;
    }
    MessageAttribute messageAttribute = attrs[0] as MessageAttribute;
    if (messageAttribute == null){
        continue;
    this.typeMessages.Add(messageAttribute.Opcode, Activator.CreateInstance(type));
    this.opcodeTypes.Add(messageAttribute.Opcode, type);
}

public ushort GetOpcode(Type type)
{
    return this.opcodeTypes.GetKeyByValue(type);
}

發現 opcodeTypes 跑到一半就crash了, 這個框架一直有個致命的問題就是流程上有exception部會跳出提示, 有時候就需要下來下斷點查看....有空真的必須好好看看這個問題怎麼解決

發現 Activator.CreateInstance(type) 執行到 MarketInfo 就掛了, 出現這個錯誤

'Activator.CreateInstance(type)' threw an exception of type 'System.MissingMethodException' object {System.MissingMethodException}

後來查看 MarketInfo.cs 發現了 constructor 沒有寫, 補上去就好了, 就這段

public MarketInfo() { }

56888-xind84hxker.png

标签: none

添加新评论