(Can't believe this hasn't already been asked, but I can't find a dup)
In Visual Studio with lots of projects, when I first open the solution, I sometimes get the warning Object of type "X" cannot be converted to object of type "X"
. Generally rebuilding seems to make it go away, but does anyone know what this is caused by, and how to avoid it?
UPDATE I read somewhere that deleting all your resx files and rebuilding can help. I unthinkingly tried this. Not a good idea...
I had the same error, I tried some solutions above but nothing worked for me, then I removed the content of the value tag of the data tag of my property in
resx file
.For example if the property witch produce the error is
MyProp
in aMyUserControl
user control, you will find inresx file
a data tag with the nameMyUserControl.MyProp
, remove the content of it's value tag.I came across the same problem, and while Marc's answer did help me to understand what was going wrong, it did not solve my problem. Rebuilding did not help, and I was not using serialization in this case.
Turns out my problem was happening because my project had a reference to itself (not quite sure how that happened, perhaps Resharper added the reference without me noticing?), and it was comparing the .cs file with the compiled .dll file. I simply removed the reference.
Hope this helps anyone else with the same issue!