New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with [assembly: AssemblyVersion("7.0.0.0")] - 'Error setting value to ...' #647

Closed
3F opened this Issue Sep 10, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@3F

3F commented Sep 10, 2015

I see awesome bug with deserialization in latest version, i.e. for v7.x :

Newtonsoft.Json.JsonSerializationException: Error setting value to ...

For v6.0.8 is all ok !

AssemblyVersion ?

Let me explain, In your source code I started searching some changes for this moment from: 6.0.8 (1497343) -> 7.0.1 (20cc266)

incredible, but ok, a quick test to check it... go on 7.0.1 (20cc266) and make next changes:

[assembly: AssemblyVersion("7.0.0.0")] -> [assembly: AssemblyVersion("6.0.0.0")]

build and... are all ok o_O

Forgot a some changes that should be for new major releases ?

How to reproduce:

v7.0.1

This problem reproduced only in VS Add-in wrapper (we still support X program for our users on VS2013), and are all ok for work with other our components.
Therefore, for this case, I created new clean structure for simulating problem as in real programs for a quick debug (but, you can also test this on real our program if need):

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv" verbosity:diagnostic "C:\projects\ConsoleApplication1\ConsoleApplication1.sln" /Rebuild Debug

Should be next problem:

ClientB: 'Newtonsoft.Json.JsonSerializationException: Error setting value to 'Command' on 'net.r_eg.BugsReview.NJ.CoreLibrary.ModeFile'. ---> System.InvalidCastException: =х єфрыюё№ яЁштхёЄш Єшя юс·хъЄр "net.r_eg.BugsReview.NJ.CoreLibrary.ModeFile" ъ Єшяє "net.r_eg.BugsReview.NJ.CoreLibrary.ModeScript".

with stack trace:

C:\projects\ConsoleApplication1>"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv" verbosity:diagnostic "C:\projects\ConsoleApplication1\ConsoleApplication1.sln" /Rebuild Debug
Name: 'Act1'
Mode: 'File'
Command in File mode: 'booo'
ClientB: 'Newtonsoft.Json.JsonSerializationException: Error setting value to 'Command' on 'net.r_eg.BugsReview.NJ.CoreLibrary.ModeFile'. ---> System.InvalidCastException: =х єфрыюё№ яЁштхёЄш Єшя юс·хъЄр "net.r_eg.BugsReview.NJ.CoreLibrary.ModeFile" ъ Єшяє "net.r_eg.BugsReview.NJ.CoreLibrary.ModeScript".
   at SetCommand(Object , Object )
   at Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.DynamicValueProvider.SetValue(Object target, Object value)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at net.r_eg.BugsReview.NJ.CoreLibrary.Sample.deserialize(StreamReader stream) in d:\prg\projects\BugsReview\BugsReview\Newtonsoft.Json\CoreLibrary\CoreLibrary\Sample.cs:line 75
   at net.r_eg.BugsReview.NJ.CoreLibrary.Sample.from(String data) in d:\prg\projects\BugsReview\BugsReview\Newtonsoft.Json\CoreLibrary\CoreLibrary\Sample.cs:line 47
   at net.r_eg.BugsReview.NJ.CoreLibrary.Sample.init() in d:\prg\projects\BugsReview\BugsReview\Newtonsoft.Json\CoreLibrary\CoreLibrary\Sample.cs:line 42
   at net.r_eg.BugsReview.NJ.ClientB.Connect.OnConnection(Object application, ext_ConnectMode connectMode, Object addInInst, Array& custom) in d:\prg\projects\BugsReview\BugsReview\Newtonsoft.Json\CoreLibrary\ClientB\Connect.cs:line 24'

...

v6.0.8

Change Newtonsoft.Json to old v6.0.8. Then repeat steps above and., now you can see normal state:


C:\projects\ConsoleApplication1>"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv" verbosity:diagnostic "C:\projects\ConsoleApplication1\ConsoleApplication1.sln" /Rebuild Debug
Name: 'Act1'
Mode: 'File'
Command in File mode: 'booo'
Name: 'Act1'
Mode: 'Script'
Command in Script mode: 'muahahaha'
...

please fix it, or tell me more about problem. Why is simple changes in your lib [assembly: AssemblyVersion("7.0.0.0")] -> [assembly: AssemblyVersion("6.0.0.0")] gives the problems as above.

Entry point for debugging of your lib: https://github.com/3F/BugsReview/blob/master/Newtonsoft.Json/CoreLibrary/CoreLibrary/Sample.cs#L42

@3F

This comment has been minimized.

Show comment
Hide comment
@3F

3F Sep 22, 2015

Hello... Can I hear anything about this ?!
Is anyone alive from this project o_o

this also reproduced on another pc with other environment, please fix it !

3F commented Sep 22, 2015

Hello... Can I hear anything about this ?!
Is anyone alive from this project o_o

this also reproduced on another pc with other environment, please fix it !

@3F

This comment has been minimized.

Show comment
Hide comment
@3F

3F Sep 22, 2015

Fixed...

What is it ?

C:\Program Files\Common Files\Microsoft Shared\Visual Studio\12.0\Newtonsoft.Json.dll

from where ? for what ?

I also had this on my develop machine, and similar on others pc where appeared this bug from other users...
Today I started debugging of your source, and ... yes, immediately saw this.
Always loaded from there., for any cases!

amazing coincidence (btw, first thought was about GAC and similar... however, you see)

well, now it works:


>devenv  verbosity:diagnostic "C:\projects\ConsoleApplication1\ConsoleApplication1.sln" /Rebuild Debug
Name: 'Act1'
Mode: 'File'
Command in File mode: 'booo'
Name: 'Act1'
Mode: 'Script'
Command in Script mode: 'muahahaha'

3F commented Sep 22, 2015

Fixed...

What is it ?

C:\Program Files\Common Files\Microsoft Shared\Visual Studio\12.0\Newtonsoft.Json.dll

from where ? for what ?

I also had this on my develop machine, and similar on others pc where appeared this bug from other users...
Today I started debugging of your source, and ... yes, immediately saw this.
Always loaded from there., for any cases!

amazing coincidence (btw, first thought was about GAC and similar... however, you see)

well, now it works:


>devenv  verbosity:diagnostic "C:\projects\ConsoleApplication1\ConsoleApplication1.sln" /Rebuild Debug
Name: 'Act1'
Mode: 'File'
Command in File mode: 'booo'
Name: 'Act1'
Mode: 'Script'
Command in Script mode: 'muahahaha'
@JamesNK

This comment has been minimized.

Show comment
Hide comment
@JamesNK

JamesNK Sep 30, 2015

Owner

It looks like it was an assembly loading issue. If a referenced strong named assembly isn't in the right location then it will be loaded from the GAC. I'm not really an expert on stuff like this.

Owner

JamesNK commented Sep 30, 2015

It looks like it was an assembly loading issue. If a referenced strong named assembly isn't in the right location then it will be loaded from the GAC. I'm not really an expert on stuff like this.

@JamesNK JamesNK closed this Sep 30, 2015

@3F

This comment has been minimized.

Show comment
Hide comment
@3F

3F Sep 30, 2015

A main difference between ClientA & ClientB in my example above - only in domain:

  • ClientA works in our domain.
  • ClientB loaded by Visual Studio in some other domain! it's important

The Visual Studio resolves this first and ClientB can't change this behaviour, because the Newtonsoft.Json assembly is already resolved before. In general, this special case for devenv (i.e. Add-In).

On my pc I found only Newtonsoft.Json.dll & System.Net.Http.Formatting.dll in current folder:

├───microsoft shared
.....
│   │
│   ├───Visual Studio
│   │   └───12.0
│   │           Newtonsoft.Json.dll
│   │           System.Net.Http.Formatting.dll
│   │

For this case I already updated documentation

3F commented Sep 30, 2015

A main difference between ClientA & ClientB in my example above - only in domain:

  • ClientA works in our domain.
  • ClientB loaded by Visual Studio in some other domain! it's important

The Visual Studio resolves this first and ClientB can't change this behaviour, because the Newtonsoft.Json assembly is already resolved before. In general, this special case for devenv (i.e. Add-In).

On my pc I found only Newtonsoft.Json.dll & System.Net.Http.Formatting.dll in current folder:

├───microsoft shared
.....
│   │
│   ├───Visual Studio
│   │   └───12.0
│   │           Newtonsoft.Json.dll
│   │           System.Net.Http.Formatting.dll
│   │

For this case I already updated documentation

@bondarchook

This comment has been minimized.

Show comment
Hide comment
@bondarchook

bondarchook Oct 26, 2015

To @JamesNK
No .NET always prefer assembly from GAC before loading any local assemblies.
This mean that nobody should not put Newtonsoft.Json.dll into the CAG in order it to work

But you can not control that. Even if your project not use GAC but some other application can install Newtonsoft.Json.dll to GAC and you can not control that

You really need to properly change assembly version with every release
Otherwise people who use your library will always get in to this types of problems and it is even not their fault.

bondarchook commented Oct 26, 2015

To @JamesNK
No .NET always prefer assembly from GAC before loading any local assemblies.
This mean that nobody should not put Newtonsoft.Json.dll into the CAG in order it to work

But you can not control that. Even if your project not use GAC but some other application can install Newtonsoft.Json.dll to GAC and you can not control that

You really need to properly change assembly version with every release
Otherwise people who use your library will always get in to this types of problems and it is even not their fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment