wpf - How can I stop my ClickOnce install from requiring Newtonsoft.Json v4.5 in the GAC? -


we have clickonce deployment of wpf desktop application, , installed newtonsoft.json version 6.0.8 nuget package.

after making change , publishing clickonce deployment, users can't run update, because of error message:

the error message shown when updating application

the first thing strikes me odd dependency on version 4.5.0.0, when i'm using version 6.0.8.

ignoring moment, i've found online suggests ensure reference set copy local, , in application files dialog of publish settings, make sure assembly set include , required.

i've checked these, , found correct:

reference properties

enter image description here

so i'm bit stumped. how clickonce application requiring older version of assembly installed gac?

any ideas beyond obvious massively appreciated!

update 1

i don't know how useful is, i've found if set reference not copy locally (making prerequisite instead of include), , publish again, when install application, same error, correct version.

same error message version 6

update 2

interesting. if uninstall nuget package project (which removes reference), , make sure it's not in clickonce package @ all, still original error. must mean i'm referencing references newtonsoft.json version 4.5.0.0??

update 3

so found referenced project causing error. project has newtonsoft.json version 6.0.8 installed, still don't understand version 4.5.0.0 dependency comes from.

update 4

the battle continues. i've managed move responsibility around such there no newstonsoft.json reference in wpf application or projects references, , none of them have nuget package installed. can publish , install package, when run application, exception:

application startup exception

update 5

well i've found cause, , it's line of code in main view model:

var response = await client.postasjsonasync("api/common/myapimethod", data).continuewith(t => t.result.ensuresuccessstatuscode()); 

as go anywhere near postasjsonasync method, error message shown above, in update 4. however, extension method part of httpclientextensions class, lives in system.net.http.formatting assembly.

so guess question why assembly expects version 4.5.0.0 gac install, , why hasn't come before, importantly - how can prevent reliance on gac?

update 6

just spotted assembly mentioned above referenced via path ... c:\program files (x86)\microsoft asp.net\asp.net mvc 4\assemblies\system.net.http.formatting.dll ... it's asp.net mvc assembly. guess i'm faced either installing latest mvc nuget package (which seems daft wpf project) or change method connecting web api alternative (maybe preferable).

solution

zache's answer concise summary of problem. postasjsonasync method belongs system.net.http.formatting, mvc extension assembly. in turn relies on old version of newstonsoft.json, hence gac dependency.

i removed reference system.net.http.formatting , replaced code connects server, uses date newtonsoft.json serialize data being sent server.

this serialized data packaged stringcontent object , sent server, , response can deserialized json requested type.

var data = new { /* anonymous object definition*/ }; var json = jsonconvert.serializeobject(data); var httpcontent = new stringcontent(json, encoding.unicode, "application/json");  try {     var response = await client.postasync("api/mycontroller/mymethod", httpcontent).continuewith(t => t.result.ensuresuccessstatuscode());     var returndata = await response.content.readasstringasync();     var result = returndata;     var deserialized = jsonconvert.deserializeobject<t>(result); 

looking system.net.http.formatting find this nugetmusthaves-page. in turn tells assembly has dependency microsoft asp.net web api 2.2 client libraries in turn requires json.net.

how did add system.net.http.formatting assembly solution? did use nuget? try removing , installing via nuget instead, should work :)


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -