IlRuntime + protobuf-net
环境unity566,.net2.0
下载protobuf-net
https://github.com/mgravell/protobuf-net/tree/r668
因为这个vs2015就可以打开,主干需要2017
下载ILRuntime
https://github.com/Ourpalm/ILRuntime
参照
https://github.com/Ourpalm/ILRuntimeU3D/
搭建1个hotfix工程,1个unity工程,完整工程如下
https://github.com/yingsz/ILRuntime-protobuf-net
遇到的几个问题
1对于hotfix工程里,继承外部类或接口,需要编写adaptor,并注册,网上有教程
2对于hotfix工程不可以既继承外部类,同时又实现外部接口。ProtoMemberAttribute既继承了Attribute,又实现了ICompare.
这个时候需要在外部实现1个类,继承Attribute。并实现接口ICompare,比如叫CompareAttribute,然后ProtoMemberAttribute继续CompareAttribute
但是我简单粗暴的把ICompare删了
3ILRuntime里抛nullreferenceexception,这个是因为protobuf生成文件里
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
获取方法名字是“global::ProtoBuf.IExtensible.GetExtensionObject”,而ILRuntime里用名字找方法是用的是
if (m == null && method.DeclearingType.IsInterface)
{
m = GetMethod(string.Format("{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
名字是“ProtoBuf.IExtensible.GetExtensionObject”,所以会找不到方法,所以需要改成
var m = GetMethod(method.Name, method.Parameters, genericArguments, method.ReturnType, true);
if (m == null && method.DeclearingType.IsInterface)
{
m = GetMethod(string.Format("{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
if(m == null)
m = GetMethod(string.Format("global::{0}.{1}", method.DeclearingType.FullName, method.Name), method.Parameters, genericArguments, method.ReturnType, true);
}
IlRuntime + protobuf-net的更多相关文章
- python通过protobuf实现rpc
由于项目组现在用的rpc是基于google protobuf rpc协议实现的,所以花了点时间了解下protobuf rpc.rpc对于做分布式系统的人来说肯定不陌生,对于rpc不了解的童鞋可以自行g ...
- Protobuf使用规范分享
一.Protobuf 的优点 Protobuf 有如 XML,不过它更小.更快.也更简单.它以高效的二进制方式存储,比 XML 小 3 到 10 倍,快 20 到 100 倍.你可以定义自己的数据结构 ...
- java netty socket库和自定义C#socket库利用protobuf进行通信完整实例
之前的文章讲述了socket通信的一些基本知识,已经本人自定义的C#版本的socket.和java netty 库的二次封装,但是没有真正的发表测试用例. 本文只是为了讲解利用protobuf 进行C ...
- 在Wcf中应用ProtoBuf替代默认的序列化器
Google的ProtoBuf序列化器性能的牛逼已经有目共睹了,可以把它应用到Socket通讯,队列,Wcf中,身为dotnet程序员一边期待着不久后Grpc对dotnet core的支持更期待着Wc ...
- protobuf的编译安装
github地址:https://github.com/google/protobuf支持多种语言,有多个语言的版本,本文采用的是在centos7下编译源码进行安装. github上有详细的安装说明: ...
- 编译protobuf的jar文件
1.准备工作 需要到github上下载相应的文件,地址https://github.com/google/protobuf/releases protobuf有很多不同语言的版本,因为我们需要的是ja ...
- protobuf学习(2)-相关学习资料
protobuf官方git地址 protobuf官方英文文档 (你懂的需要FQ) protobuf中文翻译文档 protobuf概述 (官方翻译 推荐阅读) protobuf入门 ...
- google protobuf安装与使用
google protobuf是一个灵活的.高效的用于序列化数据的协议.相比较XML和JSON格式,protobuf更小.更快.更便捷.google protobuf是跨语言的,并且自带了一个编译器( ...
- c# (ENUM)枚举组合类型的谷歌序列化Protobuf
c# (ENUM)枚举组合类型的谷歌序列化Protobuf,必须在序列化/反序列化时加上下面: RuntimeTypeModel.Default[typeof(Alarm)].EnumPassthru ...
随机推荐
- Redis 配置文件及命令详解
==基本配置 daemonize no 是否以后台进程启动 databases 16 创建database的数量(默认选中的是database 0) save 900 1 #刷新快照到硬盘中,必须满足 ...
- Maven 命令行创建项目时 Could not find goal ‘create’ in plugin org.apache.maven.plugins:...
使用maven3.3.9 版本,进行命令行创建项目时输入以下命令创建失败 mvn archetype:create -DgroupId=com.zang.maven -DartifactId=sys ...
- android-数据库SQLite相关
android平台下的SQLite数据库是一种轻量级数据库,支持标准的SQL语句. 本文将介绍 android数据库的创建 利用sql语句对数据库增删改查 系统api数据库增删改查 数据库的事务 1, ...
- http协议---简述
http(Hypertext transfer protocol)超文本传输协议,通过浏览器和服务器进行数据交互,进行超文本(文本.图片.视频等)传输的规定. 也就是说,http协议规定了超文本传输所 ...
- Lucene4.0 LogMergePolicy
其特点是给定的段列表顺序归并,不像TieredMergePolicy那样按大小排序之后决定. norm = log(10),levelFloor=log(minMergeSize)/norm,对段列表 ...
- 基于Verilog的以2为底取对数函数log2(x)
参考资料:xilinx AXI4 Stream Peripherals 源码 //*********************************************************** ...
- MySQL:系列合集
MySQL一:初识数据库 MySQL二:库操作 MySQL三:存储引擎 MySQL四:表操作 MySQL五:数据操作 MySQL六:索引原理与慢查询优化 MySQL七:数据备份 MySQL八:视图.触 ...
- shell脚本之练习题
设计一个shell程序,添加一个新组为class1,然后添加属于这个组的30个用户,用户名的形式为stdxx,其中xx从01到30. i=1 groupadd class1 while [ $i -l ...
- 李洪强iOS开发之OC[002] - OC中注释以及@符号的使用
- SQL数据库 CRUD
1.删除表 drop table +表名 2.修改表 alter table+表名+ add(添加)+列名+ int(类型) alter table+表名+ drop(删除)+column(列) ...