.netwpfvisual-studio-2015installshieldinstallshield-le

(InstallShield) WPF Executable Calls wrong dll version if not run as administrator


Im having a very strange issue with my executable project. I have created this in release mode (x86) using InstallShield to create a package.

Recently this deployed executable has started behaving strangely (ive tried rolling back and finding the cause but this has not been of any help). When i create my executable via my InstallShield project it looks as id expect.

The problem i get is running the application. If i run as an administrator i am able to login and run everything as expected. However if i do not run this as an administrator i get the following error (at the first mentioned use of a class using newtonsoft.json.dll:

[System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() at Player.Services.DataService.UploadLogToServer(AuditDTO record)
at Player.Controller.PlayerControls.logInfo(String eventCode, String information, String className, Exception e)

]

I do not see this at all if i run as an admin. Ive tried many solutions across multiple answers for similar questions around the dll being wrongly referenced etc. None of these have made a difference. I do not have any references to any of these versions. I am currently using version 10.0.0.0 (Nuget package 10.0.3), i have also tried using version 9.0 to satisfy the errors want for version 9. this also has the same outcome as above. I have checked it's the correct dll and version for my .net framework and i have tried over 50 times to uninstall it then reinstall it, update it, manually reference it.

I have tried changing the security permissions for all users on my pc to give everything/everyone full access and rights to all folders where my executable is deployed. Again this also hasnt fixed the issue.

I have also tried clearing out all other references to newtonsoft.json.dll from PC in obvious places as well as any and all temp folders, hidden folders, visual studio and microsoft folders that contain anything related to my project or a newtonsoft.json.dll.

I cleared out all of my build (debug and release folders), my entire solution folder was cleaned and rebuilt and im still none the wiser to what is going on and how to tackle this issue.

IMPORTANT NOTE: When i have built my project (release mode) i am able to run the exe as expected (regular user) from the bin/x86/release folder of my project without the error occurring. this leads me to believe it may be something to do with install shield or my configuration of installshield? Not sure but this may be helpful information.

Any suggestions, ideas or if someone has come across something similar and fixed it, i would greatly appreciate any advice and suggestions you can give me below.



UPDATE:

Eugene B's answer has helped fix this issue. Though the fix may not be the best practice and i am still not sure why or how this occurred or even what the root problem is i will share how i have fixed the issue below:

Thanks for the suggestion. Unfortunately the logs didnt provide any helpful information on this. It does seem to be the case that a version is added that is not on my machine or referenced anywhere in my project. The last part of your answer has helped me towards fixing the problem. I added the dll reference version: 9.0.0.0 directly to the installshield files. With that i then decided to roll back my version 10.0.0.0 of the dll in the wpf project back to version 9. Finally its running as admin and a regular user again. I would love to find out what the root issue is here though. Many thanks!!

If anyone does know or understand what the root cause of the problem is and why installshield le is requesting version 9 of this file please answer or add a comment below.


Solution

  • Have a look at InstallShield project compilation log. If you don't have an assembly listed explicitly in your project, and if InstallShield determines that it's a dependency that needs to be added, it will add it for you, and it will create an entry in its compilation log (typically located in subdirectory \LogFiles). It may have added a version that either does not exist on a target machine, or is in directory with different access level, so only admins have access to it. If you haven't already, try to add the assembly explicitly to the InstallShield (InstallScript) project.