0

I have a strange issue with my generated serialization .dll. The .dll is successfully generated I can reference it in my project, all the types are contained within the namespace Microsoft.Xml.Serialization.GeneratedAssembly as expected, even the intellisense is picking up the types and namespaces. But when I go to build the project referencing any of the types within the generated assembly I get an error along the lines of:

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

Rather odd, no? The namespace clearly exists as far as intellisense is concerned and I've never had an issue like this before. I tried to regenerate the assembly, still the same problem.

For now I have run sgen.exe with the flag /keep and just copied the generated source into my project which is fine. I was just curious if there was a way to fix this issue or if anyone else has ever come across it before.

EDIT:

It turns out that the issue is because the generated assembly is targeting a version of the .NET framework greater than the assembly that is referencing it. Now the question becomes - how do I generate a serialization assembly with Sgen that targets a specific .NET framework version.

rtlayzell
  • 608
  • 4
  • 20
  • Are you containing multiple projects in your solution? If yes, are you sure set dependency? – Jumpei Aug 26 '14 at 13:48
  • The class library that contains the serializable type does not reference anything beyond the default `System.Xml` types... Actually the type I'm trying to create a serializer for has a number of attributes from various namespaces placed upon it by another code generation process (the types was generated via an xsd). None of them are beyond the default class library references but should I be referencing them in the generation process? I didn't think it would succeed if I hadn't covered my refereces – rtlayzell Aug 26 '14 at 13:50
  • I figured it out, its because I'm generating an assembly with a higher target framework version than the assembly referencing the generated serializer assembly. Though I'm not sure how I can set the target framework version with Sgen. – rtlayzell Aug 26 '14 at 14:05

1 Answers1

0

Ok so after reading the answer on this question I managed to generate a serialization assembly that has the correct "runtime version" for .NET 3.5 and everything works as expected, sorry for wasting time.

Community
  • 1
  • 1
rtlayzell
  • 608
  • 4
  • 20