I am using assembly binding, but I still get this error:
Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified
Here is my code:
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
Here are more details on the error:
=== Pre-bind state information === LOG: DisplayName = System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot LOG: Initial PrivatePath = C:\Users\Source\Workspaces\CQB\Development\Dev-branch\Azure\CloudService1\csx\Debug\roles\CQB.TaskRole2\approot
LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Source\Workspaces\CQB\Development\Dev-branch\Azure\CloudService1\csx\Debug\roles\CQB.TaskRole2\approot\CQB.TaskRole2.dll.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Redirect found in application configuration file: 4.2.0.0 redirected to 4.2.1.0. LOG: Post-policy reference: System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Attempting download of new URL file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations.DLL. LOG: Attempting download of new URL file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations/System.ComponentModel.Annotations.DLL. LOG: Attempting download of new URL file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations.EXE. LOG: Attempting download of new URL file:///C://Source/Workspaces/CQB/Development/Dev-branch/Azure/CloudService1/csx/Debug/roles/CQB.TaskRole2/approot/System.ComponentModel.Annotations/System.ComponentModel.Annotations.EXE.
I discovered the version showing for Version 4.5.0
in the library reference properties is 4.2.1.0
. When I changed the version to 4.4.1
via NuGet, the version in the properties changed to 4.2.0.0
.
So change the version of System.ComponentModel.Annotations
to 4.4.1
via nuget will resolve the issue for me.