Microsoft.WindowsAPICodePack.Shell Could not load file or assembly - c#

When i try to run a project using this dll. i get the following error:
Could not load file or assembly 'Microsoft.WindowsAPICodePack.Shell,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=90ba9c70f846762e' or
one of its dependencies. The system cannot find the file specified.
I've tried all possible combinations of these properties:
Also tried re-adding the reference.
There are two projects in the solution, the reference is in both (if that info is of any use).
It's a C#, .NET 4 project.
What is causing the error?

even MS package gives the same error, I did install this one https://github.com/contre/Windows-API-Code-Pack-1.1 and it worked perfectly

It's not actually a solution so solved the error. But I found an alternative package that works well:

I had the same problem and resolved it by setting the default folder path, like so:
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.InitialDirectory = Directory.GetCurrentDirectory();

I can't speak for JJ_Jason, but I believe I was receiving this error because I was using the wrong Microsoft.WindowsAPICodePack.Shell.
There are three:
1: Microsoft.WindowsAPICodePack.Shell, authored by Microsoft
2: Microsoft.WindowsAPICodePack.Shell, authored by Lischee
3: Microsoft-WindowsAPICodePack.Shell, authored by rpastric
I was receiving this error with the Lischee version of the package but when I switched over to the Microsoft version, the issue went away. I'm assuming Malior and BigOmar had the same issue but in reverse.

Related

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.2.0.0,

I created a .net core 2.2 project using the AWS Lambda function template. Added a MySQL EntityFramework nuget package. My project targets .NET Core 2.2. I have code which uses DbContext and EF stuff. When I run the app using their lambda test tool, I get this error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.2.0.0, .....
Using Process Monitor, I can see the app is trying to load Microsoft.EntityFrameworkCore.dll from ...\bin\Debug\netcoreapp2.2\Microsoft.EntityFrameworkCore.dll which doesn't exist.
My question is why aren't any of the supporting assemblies in that folder? The only assembly (.dll file) in the folder is my app's.
Following step help you to solve this problem:
Delete all bin and obj folders.
Clean Solution. [Build>Clean Solution].
Rebuild Solution
Try to use some type of Microsoft.EntityFrameworkCore namespace explicitly somewhere in your code. For example:
var _ = new Microsoft.EntityFrameworkCore.DbContextOptionsBuilder();
It sould force the build to copy the assembly to result directory.
I have some ideas.
Firstly check, if the folder that you want to refer allows the Visual to have access.
If it do not work, try reinstaling packages through nugget (If I remember correctly I had this same error.). If it shows that its not installed in nugget manager, just install it, even a few times.
Here is the anwser for your question at the end:
Where does NuGet put the dll?
I had a similar problem, in my case removing the line from the .csproj file helped
<PublishReadyToRun>true</PublishReadyToRun>

Using Autofac get error "could not load file or assembly 'system.web.mvc version=5.1.0.0"

I'm using Autofac.Mvc 4.0.0.0 and my System.Web.MVC version is 5.2.3.0. It's build success but getting this error when i run project.
This problem is solved, just post it to help someone like me.
Finally, it's a Microsoft's bug already report here, This issue on github is closed, see detail. Any "could not load assembly" exception may be due to this bug.
Point is don't let project directory start with "#" after drive letter if you are using AssemblyBinding(two project using different version of same assembly, config AssemblyBinding let them using same version when one project reference another)

Newtonsoft.Json version 8.0.2 Could not load file or assembly Error

I'm attempting to parse a JSON file in Class Library within an Web API solution. It is a regular C# Class Library, not the Portable kind.
I've tried every single answer mentioned here, but it still doesn't work! I keep getting the same error which is:
Could not load file or assembly 'Newtonsoft.Json, Version=8.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)":"Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Here is the code:
public IList<BranchRM> AllBranches()
{
var result = new List<BranchRM>();
var dataSourcePath = AppDomain.CurrentDomain.BaseDirectory + "Data/branches.json";
var dataAsText = File.ReadAllText(dataSourcePath);
if (string.IsNullOrEmpty(dataAsText)) return result;
var branchList = JsonConvert.DeserializeObject<List<Branch>>(dataAsText);
result = AutoMapper.Mapper.Map<List<BranchRM>>(branchList);
return result;
}
I was fixing some old code in one of my Windows Phone 8 solutions and thought of updating the NuGet packages and was greeted with the same issue.
A comment from StivOstenberg here helped me solve this.
This is what I did:
Removed the NuGet package. Just clicked 'Uninstall' from NuGet manager. Make sure to remove it from every project in the solution separately.
Clean Solution. Rebuild Solution.
Now, remove the using statement from your entire solution! Can be done with a quick find and replace for using Newtonsoft.Json on 'Entire Solution'.
Repeat step 2. (Ignore the errors)
Add package again from NuGet manager & build (Ctrl+Shift+B).
Finally (almost), for every error shown, go to the particular page and add reference again.
Repeat step 2 and Run.
There might be some redundant steps, but this is exactly what I did, and it worked. Hope it helps you too.
Make sure there are no conflicting versions of Newtonsoft in a parent assembly!
In a child-assembly I wanted to use Newtonsoft.Json.8.0.3.
Well the StartUp project is an MVC5 web app. There I use the BundleTransformer.Less.X.X.X which had a dependency to Newtonsoft.Json.8.0.2. Upgrading NewtonSoft.Json to 8.0.3 (all the same version now) resolved it for me.

Interop service does not work with NuGet WatiN

I'm trying to use WatiN; I've installed the latest version through NuGet.
Everything worked great, until I changed the EmbedInteropTypes to false - for some reason, I get a new error now;
My system cannot locate Interop.SHDocVw.
This triggers on the first line of the first test they feature on their site:
using (var browser = new IE("http://www.google.com");
The exact message is:
Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e' or one of its dependencies.
What happened? Why did it happen?
In the end it was rather simple - I just had to build the solution and copy the DLL from the folder to the project.

Migrator.NET MSBuild - Could not load file or assembly 'Migrator.Framework'

I've installed Migrator.NET using NuGet but when I attempt to run a migration using MSBuild I get the following error. I see that its having trouble accessing the Migrator.Framework assembly but I am unsure as to why or where specifically I need to put the DLL in order to get it to run.
C:\Users\Cody\src\App\App.Migrations\App.Migrations.csproj(64,5): error MSB4062: The "Migrator.MSBuild.Migrate" task could not be loaded from the assembly C:\Users\Cody\src\App\App.Migrations..\packages\MigratorDotNet.0.9.0.33276\tools\Migrator.MSBuild.dll.
Could not load file or assembly 'Migrator.Framework, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Does anyone have any insight? I've spent far too long fiddling with this.
It turns out the issue was in fact that it was looking for version 0.0.0.0. I downloaded the project and recompiled the Migrator.Framework binary as version 0.0.0.0 as a quick fix. The real solution is recompiling Migrator.MSBuild.dll to look for the proper version of Migrator.Framework.
I'll see if this was a one-off error or if I can reproduce it, and submit it as a bug to the Migrator.NET team if it is in fact a bug with the NuGet package.

Categories