- Home /
sharpSerializer Error CS0103 when webplayer selected in build settings
I'm using an external library sharpSerializer in Unity 4.2.1f4 (latest), and I'm getting this error message:
Assets/Scripts/Libraries/SharpSerializer/Advanced/PropertyProvider.cs(302,57): error CS0103: The name `Items' does not exist in the current context
But I'm only getting that message when webplayer is selected in the build settings. When a standard desktop build is selected, everything compiles and I can run in-editor and build a standalone executable. SharpSerializer works just fine.
So there's obviously some sort of problem building the webplayer with this library, but I don't even know where to start to fix this problem. I want to be able to build for webplayer.
The specific file that's throwing the error is here in the library's repo:
The offending line is near the end of the file. I'm only using the contents of the SharpSerializer.Library folder.
Answer by ArkaneX · Sep 06, 2013 at 09:09 AM
I've just checked, and it seems there's a difference in implementation of Collection class between mscorlib used for web player and the one used for standalone. In standalone implementation you can find Items property, while web player implementation doesn't contain it. Additionally, in Unity Mono Compatibility page, you can see that there's no Items property under Collection class.
I guess you can compile sharpserializer by yourself, changing the offending part of source code to
for(int i=0; i<this.Count; i++)
{
var item = this[i];
if (item.Type == type) return item;
}
But I think you can encounter a lot more errors during compilation.
Another option would be considering other serialization libraries. Maybe JSON-based?
Hm, I've been considering JSON because it's more readable, anyway. Okay, thanks for the answer! Can you quickly let me know how you found that information? I didn't know where to look.
Sure :)
I added a class derived from $$anonymous$$eyedCollection to my test project, used Items property inside and then compiled for standalone - everything was fine in Visual Studio and in Unity. Then I changed target platform to web and compilation failed in Unity, though in Visual Studio it was ok.
After this, I changed target framework in Visual Studio project to Unity 3.5 Web Base Class Libraries, and compilation failed. Checking through Collection class metadata I saw no property named Items. This indicates, that mscorlib version for web is different.
And then I checked $$anonymous$$ono Compatibility page, just to confirm that the property is missing indeed.
Okay, thanks for that. I guess I'll try the compact version of the library, and if that breaks I'll look into other options.
Your answer
![](https://koobas.hobune.stream/wayback/20220613113646im_/https://answers.unity.com/themes/thub/images/avi.jpg)