12

When trying to deserialize using the ComponentSerializationService, errors are populated that references were not found:

public ICollection Deserialize(object serializationData)
{
    var serializationStore = serializationData as SerializationStore;
    var componentSerializationService = _serviceProvider.GetService(typeof(ComponentSerializationService)) as ComponentSerializationService;
    var collection = componentSerializationService.Deserialize(serializationStore);
}

Errors such as :

Could not find type 'System.Drawing.Size'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

Here I've passed through a Button control and set the size property.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
JL.
  • 78,954
  • 126
  • 311
  • 459
  • Would be good if you at least provided complete example of what you are doing. – Evk May 17 '16 at 08:33
  • Are serialization/deserialization happens in seprated projects? – Mehdi May 18 '16 at 22:17
  • Is your application WPF or WinForm ? – romain-aga May 21 '16 at 13:37
  • @JL. Did you had a look at this link: http://stackoverflow.com/questions/19009386/could-not-find-type-xxx-xxx-xxx-please-make-sure-that-the-assembly/ There is a resolution mentioned by the guy questioner himself – Gandhi May 23 '16 at 10:49
  • @JL. I also suggest you to have a look at this link - http://digital.ni.com/public.nsf/allkb/D45F515667FCA37A86257E590083690E which may help – Gandhi May 23 '16 at 12:45

1 Answers1

1

I remember that I had this "could not find type System.Drawing.Size" some time back and that I spent way too many hours fixing it. I don't really remember what it was that finally fixed it and I don't think that choosing Any CPU is a problem at all. Although it wasn't the very same context as yours I still think it's worth trying the following since it could be a problem connected to referencing different versions of the System.Drawing.dll from several projects inside your solution.

Thus, try double checking the solution for inconsistencies in the versions used (even if the packages.config entries are looking ok) and make sure they all are referencing the same version (.net461 for example).

In my case, some of the 30+ libraries in the solution turned out to be using .net45; I used a tool called Target Framework Migrator to fix this. You can get it through Tools => extensions and updates => Online => Visual Studio Gallery

and then type Target Framework Migrator in the Search Field.

I do remember, that I also upgraded .Net to 4.6.1 during my attempts to fix the problem ... maybe you could try this too ... but in any case running the Target Framework Migrator for your own Libraries (and restarting VS 2015 on the way) is definitely worth a try.

Good luck!

dr. rAI
  • 1,773
  • 1
  • 12
  • 15