c# - System.TypeLoadException: Access is denied when using MessagePack -


i'm trying use messagepack serialize objects, whenever try run serialization i'm getting unhandled exception error.

here's code:

cscdp_tcpclient.cs

using system.text; using system.threading.tasks; using system.net.sockets; using system.diagnostics; using system.io; using msgpack; using msgpack.serialization;  namespace cscdpapp {     class cscdp_tcpclient     {         public void connect(string server, int portno, script script)           {              var serializer = messagepackserializer.get<script>();             var tempstream = new memorystream();             serializer.pack(tempstream, script);              tempstream.position = 0;              var deserializedobject = serializer.unpack(tempstream);             debug.writeline("same object? {0}", object.referenceequals(script, deserializedobject));         }     } } 

script.cs:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks;  namespace cscdpapp {     class script     {         public string cardid;         public string time;         public string device;         public string command;          public script()         {             //parameterless constructor serialization         }          public script(string cardid, string time, string device, string command)         {             this.cardid = cardid;             this.time = time;             this.device = device;             this.command = command;         }      } } 

and i'm calling in main with:

        cscdp_tcpclient tcpclient = new cscdp_tcpclient();         script tempscript = new script("test1","test2","test3","test4");         tcpclient.connect("0.0.0.0",1,tempscript); 

and here's error i'm getting:

unhandled exception: system.typeloadexception: access denied: 'msgpack.serial ization.messagepackserializer`1[cscdpapp.script]'.    @ system.reflection.emit.typebuilder.termcreateclass(runtimemodule module, nt32 tk, objecthandleonstack type)    @ system.reflection.emit.typebuilder.createtypenolock()    @ system.reflection.emit.typebuilder.createtype()    @ msgpack.serialization.emittingserializers.fieldbasedserializeremitter.crea teconstructor[t]()    @ msgpack.serialization.emittingserializers.serializeremitter.createinstance [t](serializationcontext context)    @ msgpack.serialization.emittingserializers.ilemittingserializerbuilder`2.<> c__displayclass5a.<createserializerconstructor>b__59(serializationcontext contex t)    @ msgpack.serialization.abstractserializers.serializerbuilder`3.buildseriali zerinstance(serializationcontext context)    @ msgpack.serialization.automessagepackserializer`1..ctor(serializationconte xt context, iserializerbuilder`1 builder)    @ msgpack.serialization.messagepackserializer.createinternal[t](serializatio ncontext context)    @ msgpack.serialization.serializationcontext.getserializer[t](object provide rparameter)    @ msgpack.serialization.messagepackserializer.get[t](serializationcontext co ntext, object providerparameter)    @ cscdpapp.cscdp_tcpclient.connect(string server, int32 portno, script scrip t) in d:\tfs\msvc 2013_ctsdev1\commoncomponents\sdnet\tools\cscdpservice\cscdpap p\cscdp_tcpclient.cs:line 21    @ cscdpapp.program.main(string[] args) in d:\tfs\msvc 2013_ctsdev1\commoncom ponents\sdnet\tools\cscdpservice\cscdpapp\program.cs:line 64 

i have visual studio project in d: drive, , i've checked permissions correct. have messagepack.dll in same directory compiled executeables , have reference linked. there might possibly missing?

figured out! script class wasn't declared public why serializer couldn't find it


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -