visual studio 2012 - Sgen throws an error with internal setter in VS2012 -


does sgen generate xml serialization assemblies if setters public?

i've got class in dummyproject:

 public class dummyclass  {    public int sequence { get; internal set; }  } 

in assemblyinfo.cs, i've declared this:

 [assembly: system.runtime.compilerservices.internalsvisibleto("dummyproject.xmlserializers")] 

in csproj, i've put this:

   <target name="afterbuild"   dependsontargets="assigntargetpaths;compile;resolvekeysource" inputs="$(msbuildallprojects);@(intermediateassembly)" outputs="$(outputpath)$(_sgendllname)"> <sgen buildassemblyname="$(targetfilename)" buildassemblypath="$(outputpath)" references="@(referencepath)" shouldgenerateserializer="true" useproxytypes="false" keycontainer="$(keycontainername)" keyfile="$(keyoriginatorfile)" delaysign="$(delaysign)" toolpath="$(sgentoolpath)">   <output taskparameter="serializationassembly" itemname="serializationassembly" /> </sgen> 

current error is:

cannot deserialize type 'dummyproject.dummyclass' because contains property 'sequence' has no public setter.

what have tried: 1. now, if take out internal setter, have no problems generating dummyproject.xmlserializer.

am missing something?

my assemblyinfo.cs not contain listed in 1 of pitfalls:

[assembly: assemblykeyfile("")] [assembly: assemblykeyname("")] 
  1. i have tried signing assemblies , modifying internalsvisibleto include public key still same error.

is problem internalsvisibleto?

base on post, sgen should still able generate xml serialization assembly internal setter.

sgen, internalsvisibleto , assembly signing

  1. i didn't use post build steps generate xml serialization assembly. did in developer command prompt , assembly created classes no internal setters. now, copied assembly project output & change property setter internal. i've got error during serialization because of internal setter.
    of course, i've added internalsvisibleto in assemblyinfo.cs..

i think joe may have found solution:

"in internalsvisibleto attribute, need specify full public key, not public key token.

see answer similar question , msdn article info on how public key."

reference

sgen, internalsvisibleto , assembly signing


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -