SerializationStore not finding references
Asked Answered
S

1

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.

Saintmihiel answered 3/3, 2016 at 8:20 Comment(5)
Would be good if you at least provided complete example of what you are doing.Continuity
Are serialization/deserialization happens in seprated projects?Washroom
Is your application WPF or WinForm ?Obligation
@Saintmihiel Did you had a look at this link: #19009886 There is a resolution mentioned by the guy questioner himselfFootslog
@Saintmihiel I also suggest you to have a look at this link - digital.ni.com/public.nsf/allkb/… which may helpFootslog
R
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!

Reims answered 22/5, 2016 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.