c# - XmlSerializers with addin outlook -
i’m trying create add-in outlook , have issue deserialization , antivirus program.
i’ve noticed when add-in tried deserialize data, .net framework created temporary dll in “c:\users\{username}\appdata\local\temp\" folder.
dll existed short time, time time antivirus locked , add-in thrown error message file used process.
i’m tried rid of temporary dll , found recommendations use sgen tool creation of xmlserializers.dll.
i generated myassembly. xmlserializers.dll strong name , placed folder add-in (c:\program files (x86)\myaddin). doesn’t help.
then tried place myassembly. xmlserializers.dll gac , outlook folder, had no success. when dll called gac got following error message, dll has no reference.
"system.io.filenotfoundexception: not load file or assembly or 1 of dependencies. system cannot find file specified."
please add thoughts how can rid of temporary dll
when xmlserializer type first constructed, internally xml serialization engine generates c# code serialize , deserialize type, writes %temp% in temporary file(s), compiles , loads resulting assembly, deleting temporary files. (subsequent usages of xmlserializer reuse created assembly, see here details.)
it looks though antivirus software being ultra-aggressive @ scanning "unexpected" files created outlook process, trapping creation of file , scanning results. while under circumstances seem praiseworthy, conflicts microsoft's design xmlserializer.
so, this? have several options:
switch
datacontractserializer, not use architecture.datacontractserializerless flexiblexmlserializer, however, , may not able parse xml without preprocessing it.enable precompiled serialization assemblies. it's not sufficient set
generateserializationassemblies = onspecified in documentation, have jump through several hoops make work. see answers generating xml serialization assembly part of build ways it. able make accepted answer work old visual studio 2008 editing project file described , removingplatform="$(platform)"attribute. might need tweak answer differently vs version.after enabling pre-generated serialization dlls verified process monitor no files written
%temp%when deserializing xml in test console application.see here: boost performance pre-generated xmlserializers.
update
after bit of testing, found that, if root object not exist in assembly building, or if generic collection
list<t>ort [], precompiled serializer assemblies not used. however, making non-generic subclass oflist<t>re-enables serializer assemblies, e.g.public class rootobjectlist : list<rootobject> { }.for more, see here: all xmlserializer performance , sgen.
convert xml json json.net, deserialize json.
Comments
Post a Comment