Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SerializationStore not finding references

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.

like image 962
JL. Avatar asked Mar 03 '16 08:03

JL.


1 Answers

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!

like image 69
dr. rAI Avatar answered Nov 03 '22 19:11

dr. rAI