2

I've added the XBox Live Unity asset package to my project and I'm getting this error in Unity. It doesn't show in Visual Studio strangely but it stops me from running my app.

error CS7069: Reference to type `System.ComponentModel.INotifyPropertyChanging' claims it is defined assembly `System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found

The line the error refers to is as follows

JObject response = JsonConvert.DeserializeObject( request.text ) as JObject;

request is a Unity WWW object. I was using this asset package in my app but I've removed it as it looks like XBox Live includes a precompiled dll of this already?

Real World
  • 1,593
  • 1
  • 21
  • 46
  • Ah yes... It's a hassle. I got this as well at some point, I think I just completely removed json.net and imported it again. The reason is that when you imported the `Xbox live unity asset package` Unity overwrites your (i presume) custom import of json.net. If I'm ever in need of serializing json, I'd use the built in JsonUtility rather than the hassle it is to implement an external c# library not "officially" supported by Unity. It works but Unity doesn't play nice with it. – Fredrik Schön Mar 03 '17 at 11:32

2 Answers2

1

So it looks like JObject is the problem. Changing to JContainer solves the problem without any further code changes

Real World
  • 1,593
  • 1
  • 21
  • 46
1

The JObject class is defined in Json.NET as:

public partial class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged

while JContainer is defined as:

public abstract partial class JContainer : JToken, IList<JToken>

When you use JObject, Unity is expecting to be able to find the INotifyPropertyChanged implementation, which it doesn't seem to be able to find.

My first assumption was that that class did not exist in the .NET 2.0 Subset, but I've verified (in Unity 5.5) that it is available. Can you provide a bit more detail and let me know what version of Unity you are using?

Ben Randall
  • 1,205
  • 10
  • 27
  • Thanks for the reply. I'm building with Unity 5.5.2 but JObject worked before I imported the XBox asset package. Something in that package must be including a different version of a library from the JSON.net asset package I linked in the OP. – Real World Mar 14 '17 at 09:07
  • Do you know which other package you might have been using that could have been causing the problem? I would be interested in seeing if I can determine exactly what caused the issue so that we can document it or workaround it. – Ben Randall Mar 21 '17 at 20:00
  • As far as I know, this one https://www.assetstore.unity3d.com/en/#!/content/11347 – Real World Mar 22 '17 at 08:49
  • Ah yes, I looked at using that library, but since we obviously can't depend on a paid unity asset we're using straight up Json.NET for now (yes, I realize there are some issues with this). Hopefully these sorts of conflicts don't come up too often. It __SHOULD__ be possible for you to build the SDK libs yourself with a reference to this version of Json.NET if needed. – Ben Randall Mar 26 '17 at 05:45