SSRS Delivery Extension not found - reporting-services

I'm trying to develop a delivery extension for SSRS.
I created a dll with one class. The class implements both IExtension and IDeliveryExtension interfaces. I copied the built dll file (MyExtension.dll) to the report's server bin folder. It is not in default location, but it should not be a problem:
D:\SSRS\MSRS13.MyInstanceName\Reporting Services\ReportServer\bin
In rsreportserver.config I added this in Extensions/Delivery:
<Extensions>
        <Delivery>
            <Extension Name="My Extension" Type="My.Extensions.MyExtension,MyExtension" Visible="true" />
In rssrvpolicy.config I have something like this:
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust">
<IMembershipCondition class="UrlMembershipCondition" version="1" Url="$CodeGen$/*" />
</CodeGroup>
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="MyCustomCodeGroup" Description="trying out delivery extension">
<IMembershipCondition class="UrlMembershipCondition" version="1" Url="D:\SSRS\MSRS13.MyInstanceName\Reporting Services\ReportServer\bin\MyExtension.dll" />
</CodeGroup>
I do not see the extension when I create a new subscription. In log I keep getting this error:
extensionfactory!ReportServer_0-1!155c!02/18/2019-17:34:56:: e ERROR: Exception caught instantiating My Extension report server extension:
Microsoft.ReportingServices.Diagnostics.Utilities.ServerConfigurationErrorException:
Konfigurationsfehler beim Berichtsserver: . --->
System.IO.FileNotFoundException: Could not load file or assembly
'MyExtension.dll' or one of its dependencies. The system cannot find
the file specified..
library!ReportServer_0-1!1c78!02/18/2019-17:34:56:: e ERROR: Throwing
Microsoft.ReportingServices.Diagnostics.Utilities.NotEnabledException:
,
Microsoft.ReportingServices.Diagnostics.Utilities.NotEnabledException:
Die angeforderte Funktionalität ist zurzeit nicht aktiviert.;
I added the MyExtension.dll to GAC and restarted report server. I granted full permissions for the dll file to the SSRS windows service account and verified the account can see it. Still no success...
What am I missing?

I finally found the problem, it was .NET framework version. My assembly was compiled for .NET Framework 4.6.1. When I switched to .NET Framework 3.5, all worked fine.
Here are details:
https://support.microsoft.com/en-us/help/2869522/the-net-framework-4-x-assemblies-are-not-supported-in-sql-server-repor
Microsoft SQL Server Reporting Services (SSRS) supports extensions by including custom extensions and custom code. However, SSRS does not support Microsoft .NET Framework 4.x-based assemblies. Therefore, you cannot load a .NET Framework 4.x assembly.
There is another problem, because I cannot reference assemblies built with .NET Framework 4.x ...
Anyway, I hope this can help someone...

Related

SSRS 2016: Report Delivery Extension to send report email via MicrosoftGraph&AzureIdentity, but error in assembly version of Microsoft.Identity.Client

Microsoft announced the expiration of Basic Authentication in Exchange Online except STMP AUTH, but no guarantee on using it for long term. So, I decide to start the change with our Reports delivery in SSRS 2016 which mainly via SMTP email right now.
After reading many sources, I found that SSRS has Report Delivery Extension which we can build assembly to customize new Delivery Method, and from here I can send the Report Email through Microsoft Graph & Azure Identity.
Link of delivery extension
In the Project, I added Nuget Package of:
Microsoft Graph package version 4.47
Azure Identity version 1.8
the VS automatically add other dependencies to project and I can build the project successfully without any Warnings or Error
However, deploying the assembly to SSRS, after the subscription runs, I got the error in the log as following:
notification!WindowsService_0!59ac!11/18/2022-16:42:08:: i INFO: Notification 27e69a92-12b9-4ab8-984f-d5910af77de7 completed. Success: True, Status: Error: Could not load file or assembly 'Microsoft.Identity.Client, Version=4.46.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I check carefully the dependency of other assembly in nuget website, but nothing indicates that I'm using wrong version. The Microsoft.Identity.Client.dll file is copied to Bin folder of ReportServer.
I tried to update the Microsoft.Identity.Client.dll file with version 4.46.0 in nuget (ignore the dependencies), but another assembly version mismatch comes up:
notification!WindowsService_0!4d94!11/17/2022-23:59:03:: i INFO: Notification b82bb214-3880-4f80-857b-cdf42cde8ff0 completed. Success: True, Status: Error: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And now, I could not find the System.Diagnostics.DiagnosticSource.dll with version 4.0.4.
I can only find version 4.0.0 or 4.3 above.
Now I'm stuck here.
Does anyone have experience on this?
How can I bypass this dependency check?
I even try to downgrade version of Azure.Identity version to lower one, but still stop at the System.Diagnostics version 4.0.4
Then I create a Console Application which I just send a test email with all latest version of assembly Azure.Identity and Microsoft.Graph on the same server (same .Net Framework 4.7.2 and same firewall configuration). It can be sent sucessfully.
I'm in doubt that SSRS 2016 has any assembly confliction which point to lower version of those assemblies.
I have the exact same problem, but with building an add-on for Act! for Windows. My code works outside Act! in a standalone .NET 4.7.2 app, but I get the exact same conflict as described above when loaded within Act!. That said, Act! itself doesn't even use Microsoft.Identity.Client (that dll is not part of it)

ASP.Net Could not load file or assembly MySql.Data

I have a ASP.Net website that connects to a MySQL data base to retrieve data. I have used NuGet to install mysql.data. Doing this added a Bin folder with the sql.data dll in it to my project. It added a reference in my web config file. and it added a packages.config to my project. All of this is expected i assume ? With these resources in place my website works when i run it from visual studio. The problem is when i upload it to a server i get the following error :
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.
Source Error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Source File: d:\DZHosts\LocalUser\bman262\www.brandonsLoginTest.somee.com\riviera horticulture\web.config Line: 7
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
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].
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1069.1
This is saying it cant find the mysql.data reference right ? What am i doing wrong ?
Here are some pictures of my solution in visual studio and my web.config
Solution
Web.config
I am tearing my hair out over this, any help would be VERY appreciated
→ You will have to make sure that the same version is installed on the server where you are deploying your project.
→ If the server to which you are deploying your project is on 64 bit, you can enable 32 bit support for this site's application pool, if your dll requires 32 bit architecture.
For anyone using similar or the same host as me if you have this problem the solution was to convert the project file to an application on the server.

Neodynamic Barcode Professional upload error for SSRS report server

I am Developing a SSRS Report for Displaying Barcode . I am Using Neodynamic Barcode Proffessional and the Report is Working fine in Developer Machine (MY Machine). When i try to Upload the Report into SSRS Report Server i get this Error Can any one Help on this. Thanks in Advance
Note : I am Using SSRS 2012 Version and The Report Server is also the Same
Error :
Error while loading code module: ‘Neodynamic.ReportingServices.Barcode, Version=7.0.2000.0, Culture=neutral, PublicKeyToken=c6b33c3093a0d4cd’. Details: Could not load file or assembly 'Neodynamic.ReportingServices.Barcode, Version=7.0.2000.0, Culture=neutral, PublicKeyToken=c6b33c3093a0d4cd' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (rsErrorLoadingCodeModule) Get Online HelpError in class instance declaration for class Neodynamic.ReportingServices.Barcode: [BC30002] Type 'Neodynamic.ReportingServices.Barcode' is not defined. (rsCompilerErrorInClassInstanceDeclaration) Get Online Help
There is an error on line 4 of custom code: [BC30451] Name 'Neodynamic' is not declared. (rsCompilerErrorInCode) Get Online Help
Put your dll Neodynamic.ReportingServices.Barcode in
Driver Server Location:\Program Files\Microsoft SQL Server\MSRS12.SQLLOCAL\Reporting Services\ReportServer\bin

Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference

Things I've tried after searching:
in Web.Config put a binding on the old version:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.1.0" />
</dependentAssembly>
Edit my .csproj file to make sure there is only one Newtonsoft reference
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
Search my computer for every Newtonsoft.Json.dll and delete every non 6.0.1 version and delete the contents of my temp folder
Repair/Reinstall the package in nuget manager console
It succeeds on building, but gets the error when going to the site.
EDIT
ok, so then I tried to reinstall like every nuget package, and it seems to have added back the 4.5 version of the newtonsoft.json.dll, but I'm getting the same error. My project's Target freamework is .NET 4.5.1 and here is the stack trace I'm getting now:
Server Error in '/' Application.
Could not load file or assembly Newtonsoft.Json or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly Newtonsoft.Json or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly Newtonsoft.Json could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Newtonsoft.Json | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/
LOG: Initial PrivatePath = c:\users\user\documents\visual studio 2013\Projects\foo\bar\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\user\documents\visual studio 2013\Projects\foo\bar\web.config
LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.
LOG: Using application configuration file: c:\users\user\documents\visual studio 2013\Projects\foo\bar\web.config
LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.5.0.0 redirected to 6.0.1.0.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/user/AppData/Local/Temp/1/Temporary ASP.NET Files/root/48686d37/9d7a6572/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///c:/users/user/documents/visual studio 2013/Projects/foo/bar/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
[FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.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)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.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)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): Could not load file or assembly 'Newtonsoft.Json, Version=6.0.1.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)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9913572
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
To solve this, I ensured all my projects used the same version by running the following command and checking the results:
update-package Newtonsoft.Json -reinstall
And, lastly I removed the following from my web.config:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
If you want to ensure all your Newtonsoft.Json packages are the same version, you can specify the version like so:
update-package Newtonsoft.Json -version 6.0.0 -reinstall
Note: To open the PMC in Visual Studio, click Tools -> Nuget Package Manager -> Package Manager Console. Thanks #Rose!
I am using Newtonsoft.Json v6.0.3, but this is what I had to do in my Web.config file:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Note that even though I am using 6.0.3, I had to put in newVersion="6.0.0.0"
In my packages.config file I have:
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
I tried the following after having already ensured that my computer had the same version in all locations and that my projects were all pointing to the same reference path. I had also made sure that the binding of the old version was their and bound to the current version of dll that I had.
I work in an environment with a strict framework and the framework team often upset the versioning with the different dll's.
How I fixed this issue was to run the package manager console within visual studio (2013). From there I ran the following command:
update-package Newtonsoft.Json -reinstall
followed by
update-package Newtonsoft.Json
This went through and updated all of my config files and relevant project files. Forcing them all to the same version of the dll. Which was initially version 4.5 before updating again to get the latest.
I had the same error message and, like you mentioned, it was due to different versions of the Newtonsoft.Json.dll being referenced.
Some projects in my MVC solution used the NuGet package for version 4 of that dll.
I then added a NuGet package (for Salesforce in my case) that brought Newtonsoft.Json version 6 with it as a dependency to one of the projects. That was what triggered the problem for me.
To clean things up, I used the Updates section in the NuGet Package Manager for the solution (off Tools menu or solution right-click) to update the Json.Net package throughout the solution so it was the same version for all projects.
After that I just checked the App Config files to ensure any binding redirect lines were going to my chosen version as below.
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
Ok, I think I got it to work now. I deleted every Newtonsoft.Json.dll on my machine that wasn't the latest version that I could find, made sure I had the latest version in NuGet, and build it and made sure that was the latest one in the bin folder, and I left the changes in the web.config and the .csproj. Now I'm on to another error, so it must be working..
After hours struggling with this... I did the following:
web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<!-- other assemblies... -->
</assemblyBinding>
</runtime>
The key to enter the correct newVersion and oldVersion number is open the project's References find the package go to its properties or click alt + enter
You'll find a section Version which in my case was 12.0.0.0 while its actually 12.0.3 when exploring with Manage NuGet.
So you need to pick the package's version from the reference properties (in my case 12.0.0.0)
Finally, clean and rebuild the project (you might want to delete the bin and obj folders before).
You might face other packages dependencies issues, i did that for all and they worked.
By commenting it out this part on my web.config solved my problem:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
But of course you need to make sure you have updated or you have the right version by doing this in your package manager console:
update-package Newtonsoft.Json -reinstall
You can solve the issue by adding below lines in web.config file.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
In my case it was just a matter of:
Tools -> NuGet Package Manager -> Package Manager Settings -> Clear Cache
The problem was caused when I remapped a TFS folder.
I have tried the steps by Oleg, and they worked for my same situation.
Steps:
Run update-package Newtonsoft.Json -reinstall in Package Manager.
Delete your bin by enabling viewing the hidden files and deleting the bin folder.
Close your Visual Studio and re-open it.
Now run your project again. I believe it should be ok!
What actually helped me was to turn off the Resharper build and to use the VisualStudio Re-Build option on my project.
from Tools>>NuGet Package Manager>>Manage Package for solution
update Newtonsoft.Json of all solutions to latest Version
if you're working with some kind of subversion:
delete the project and re-download it, it worked for me :S
I had the same issue on a Test Project that had reference to an MVC 5 project. This happened after I merged with an MVC 5 project. I fixed it by installing Visual studio 2012 updates as explained here in Andre's response.
In your visual studio go to
Tools> Extensions And Updates
Select "Updates" in the accordion list on the left.
Select "Product Updates".
Update to the newest version
I Don't know why, but in my case, even if I remove bin folder from project, when I build project it copies old version of newtonsoft.json, I copied new version's dll from packages folder and It solves for now.
If none of these works, please check this answer:
https://stackoverflow.com/a/12011221/150370
(TL;DR: Remove xml namespace from configuration tag in your config file. Otherwise binding redirects will be ignored)
In some cases if you delete your Bin and Obj folders will solve this problem.
Alright so I guess the thing to do is add my answer here to this long list versus creating a duplicate question...
If you are getting this in 2019, using .NET Core 3.0 (Preview at this time), the solution is to ensure all projects are targeting the same .NET Core version (in my case 3.0). I think I had one project in the solution targeting 2.1 and the rest were 2.2 so I probably could have stuck with 2.2...
I don't even have Newtonsoft.Json installed in any of the projects, and naturally adding it to them did not fix the issue.
If you have .NET Standard class libraries or w/e in your solution, they don't need to be on the same version, though they should probably be the latest you can go. For example, my .NET Standard class libraries are on 2.2 as there is not a .NET Standard 3.0 yet.
None of the answers, including the checked one did not work for me.
The solution was far more simple. I first removed the references from my BUS layer. Then deleted the dll's from the project (to make sure it's gone), then reinstalled JSON.NET from nuget packeges. And, the tricky part was, "turning it off and on again".
I just restarted visual studio, and there it worked!
So, if you try everything possible and still can't solve the problem, just try turning visual studio off and on again, it might help.
I resolved it by remove lower version of Newtonsoft.json.dll in bin folder and added Newtonsoft.json.dll V6.0.0.0 and removed the following web.config elements
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
</dependentAssembly>
I got the same problem with dotnet core and managed to fix it by clearing the NuGet cache.
Open the powershell and enter the following command.
dotnet nuget locals all --clear
Then I closed Visual Studio, opened it again and entered the following command into the Package Manager Console:
Update-Package
NuGet should now restore all packages and popultes the nuget cache again.
After that I was able to build and start my dotnet core webapi in a Linux container.
the solution that solved my problem for this is
goto references->right click Newtonsoft.json--goto properties and check the version
this same version should be in
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-YourDllVersion" newVersion="YourDllVersion" />
</dependentAssembly>
Easy steps.
(1)Run "update-package Newtonsoft.Json -reinstall" in package manager.
(2)Delete you bin by enabling viewing the hidden files and deleting the bin folder.
(3)Close your visual studio and re-open it.
(4) Now run your project again.
I believe it should be ok
I hit this problem because I had: project A (a desktop .exe) refer to project B (a portable .dll). A & B had different versions of JSON.Net, and so there was a loader conflict.
Once I made all the versions of JSON.net the same, it worked. (This is in effect what some of the solutions above are doing - I'm just calling out why it works)
I struggled with this recently with and older project.
I managed to track down the problem after checking what version of the dll that actually was in the bin folder.
I had a post-build script that copied dependent assemblies from a dll library folder to the bin folder. A common setup from the days before nuget.
So every time I built the post-build script replaced the correct version of Json.net with the older one
I had exactly the same issue and Visual Studio 13 default library for me was 4.5, so I have 2 solutions one is take out the reference to this in the webconfig file. That is a last resort and it does work.
The error message states there is an issue at this location /Projects/foo/bar/bin/Newtonsoft.Json.DLL. where the DLL is! A basic property check told me it was 4.5.0.0 or alike so I changed the webconfig to look upto 4.5 and use 4.5.
None of these options worked for me, in the end it was;
Test > Test Settings > *.testrunconfig
I had to add a new line
<DeploymentItem filename="packages\Newtonsoft.Json.4.5.8\lib\net40\Newtonsoft.Json.dll" />
Make sure the path and version is correct for your setup.
This problem was not solved for me by refreshing NuGet Packages or by performing a "Clean" on the project. It was solved by clearing out the "obj" folder manually.
Here is my solution to this problem,make sure the version number in appconfig or packageconfig is same as the reference version in your references.
See here
In my case, at the message of error was "version 6.0.0", but this version is not available to install, so i installed the "6.0.1 version" at my project and solved my problem.
install-package Newtonsoft.Json -Version 6.0.1 -Project MyProjectX

Visual Studio settings files corrupt / MySQL connection issues

My Visual Studio 2012 Professional is having problems with a three project solution.
I have been struggling all day with a LinqToMySQL.edmx file and getting a MySQL data connection option to appear in Server Explorer.
For this I have tried installing EFTools6.1.0ForVS2012. The mysql connector I have tried is mysql-connector-net-6.7.4. This worked at one point but other problems with MySQL dll versions means I am back to square one (when I got the latest version of the DLL which I got from nuGet 6.8.3, it was still looking for 6.7.4). I have since got 6.7.4 and added the reference to the dll for all project. I've also tried editing machine.config to look for the correct mysql data provider. Still no joy.
But now...
For each solution the app.config or web.config files can't be read when trying to access Properties > Settings.
An error occurred while reading the app.config file. The file might be
corrupted or contain invalid XML
All files seem valid when checked under an XML validator.
When opening a project in VS2012 I get the error:
Microsoft Visual Studio
The ProviderPackage package did not load correctly.
The problem may have been caused by a configuration change
or by the installation of another extension. You can get more
information by examining the file
t:\Users\John\AppData\Roaming\Microsoft\VisualStudio\11.0\A
ctivityLog.xml.
When trying to create a new project I get:
Failed to create a 'ImageSource' from the text
'..\lmages\Medium.png'.
After re-installing Visual Studio the problem persists.
In the activity log the last errors are:
<entry>
<record>235</record>
<time>2014/03/25 10:28:31.202</time>
<type>Warning</type>
<source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>The catalog cache file is not up-to-date and has to be regenerated:</description>
<path>C:\Users\John\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache\Microsoft.VisualStudio.Default.cache</path>
</entry>
<entry>
<record>236</record>
<time>2014/03/25 10:28:31.211</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [Visual Studio Component Model Host Package]</description>
<guid>{49D12072-378B-4FFA-A09E-40E0B5D097CC}</guid>
<hr>80131902</hr>
<errorinfo>Configuration system failed to initialize</errorinfo>
</entry>
<entry>
<record>237</record>
<time>2014/03/25 10:28:31.241</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [Visual Studio Component Model Host Package]</description>
<guid>{49D12072-378B-4FFA-A09E-40E0B5D097CC}</guid>
<hr>80131902</hr>
<errorinfo>Configuration system failed to initialize</errorinfo>
</entry>
Looks like most of these errors were caused by malformed XML in the machine.config file in the framework folder. The machine.config file in framework64 was fine which must have caused me confusion. That's what editing with notepad gets you!
Still having problems with the mysql connector but that's a separate issue.