1

I have produced a custom class serializer for a sole class contained in 'VcdcClassStructure.dll' using sgen as-per the documentation. The documents now state that all I need to do is

  1. Add assembaly references to both 'VcdcClassStructure.dll' and the sgen-generated 'VcdcClassStructure.XmlSerializers.dll'.

  2. Add references to the namespace that contains the newly generated serialization classes via

    using VcdcClassStructure; using Microsoft.Xml.Serialization.GeneratedAssembly;`

(I have confirmed that the namespaces are correct using DotPeek).

I have then changed my code from

XmlSerializer serializer = new XmlSerializer(typeof(message));
serializer.Serialize(writer, vcdMsg);

to

messageSerializer serializer = new messageSerializer();
serializer.Serialize(writer, vcdMsg);

but on compilation I am getting

The type or namespace name 'VcdcClassStructure' could not be found (are you missing a using directive or an assembly reference?)

and

The type or namespace name 'Xml' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

I have reference the relevant assemblies and added the using code for the namespace. Why is the compiler complaining about these references?

Thanks for your time.


Edit. To prove that I have not missed any of the steps above.

enter image description here

MoonKnight
  • 23,214
  • 40
  • 145
  • 277
  • Please toggle the "2 Warnings", so we can see them - I hope they will be revealing – Marc Gravell Sep 02 '13 at 13:24
  • Ah, damn. So sorry to waste your time. They were reviling. The DLLs generated are targeting a higher .NET framework than the application... Stupidity yet again by me. Thanks very much for your help... – MoonKnight Sep 02 '13 at 13:29

1 Answers1

1

I've checked, and the process described works correctly. I would have to assume, therefore, that you've made an error in the steps. It works fine (note: the type I created in the library was SomeType, hence the names):

enter image description here

You might want to try going through the steps again.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Mark, thanks for the reply. I have checked this thoroughly, and I can assure you that the steps described above are indeed what I have done. One complexity I thought un-relevant was that I am adding these references to a class library, but this should make no difference anyway. Again, thanks for your time. – MoonKnight Sep 02 '13 at 13:13
  • I have added the same screen shot as yours to show I have not missed out anything. Do you have any ideas what could be wrong? – MoonKnight Sep 02 '13 at 13:20
  • Note: it isn't clear in the screen, but my references there are all *file* references, not *project* references. In many ways, once you've built the custom serializer you want to **not build VcscClassStructure again** - I would recommend not even having it in the solution. Is this perhaps because you are using a project reference? – Marc Gravell Sep 02 '13 at 13:21
  • @Killercam in your error list, can you please tell me what the "2 Warnings" are? I have a sneaky suspicion it will be important. – Marc Gravell Sep 02 '13 at 13:22
  • I have put the errors in the initial question. They are Assembly Reference errors. My references are also file references, referencing the DLL used by sgen and the DLL generated by sgen... – MoonKnight Sep 02 '13 at 13:27