[c#] System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application

I'm having a strange problem with deploying an application, which references an assembly, written in managed c++.

I've created an assembly X, compiled it and referenced it in an exe file, called Starter.

Starter.exe starts normally on local mashine. However, when I copy ALL contents of the starter debug folder to a virtual mashine, and try to start it there, it crashes with following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or 
assembly 'X' or one of its dependencies. The specified module could not be found.

This does not make any sense to me, because X is right in the same folder as Starter.exe.

What could be causing this problem?

UPDATE

I've examined the dependencies in Reflector on the target machine, and it was able to find files for all of those.

I've also changed the configurations to x86/win32 for all projects.

UPDATE

Here are the logs from Fusion Log (location: C:\FusionLog\Default\Starter.exe\X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null.HTM):

*** Assembly Binder Log Entry  (6/4/2012 @ 1:56:13 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = MENKAUR-7683827\Administrator
LOG: DisplayName = X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Starter.exe
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe.Config
LOG: Using host configuration file: 
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:/Documents and Settings/Administrator/Desktop/tmp/k;k/X.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
LOG: Binding succeeds. Returns assembly from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll.
LOG: Assembly is loaded in default load context.

The only errors are in C:\FusionLog\NativeImage\Starter.exe\ directory:

*** Assembly Binder Log Entry  (6/4/2012 @ 1:56:13 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Documents and Settings\Administrator\Desktop\tmp\k;k\Starter.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = MENKAUR-7683827\Administrator
LOG: DisplayName = BookmarkWiz.Kernel, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/tmp/k;k/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Starter.exe
Calling assembly : Starter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image X, Version=1.0.4538.22813, Culture=neutral, PublicKeyToken=null.
WRN: No matching native image found.
LOG: IL assembly loaded from C:\Documents and Settings\Administrator\Desktop\tmp\k;k\X.dll.

I cannot sign the assembly, as it references several other assemblies, which are not signed

This question is related to c# .net deployment .net-assembly managed-c++

The answer is


I also had the same issue when I tried to install a Windows service, in my case I managed to resolved the issue by removing blank spaces in the folder path to the service .exe, below is the command worked for me in a command prompt

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

Press ENTER to change working directory

InstallUtil.exe C:\MyService\Release\ReminderService.exe

Press ENTER


I resolved this problem by renaming the DLL. The DLL had been manually renamed when it was uploaded to its shared location (a version number was appended to the file name). Removing the version number from the downloaded file resolved the issue.


's up guys i read every single forum about this topic i still had problem (occurred trying to project from git)

after 4 hours and a lot of swearing i solved this issue by myself just by changing target framework setting in project properties (right click on project -> properties) -> application and changed target framework from .net core 3.0 to .net 5.0 i hope it will help anybody

happy coding gl hf nerds


For me, I started the app from within windows explorer (by double clicking on it). Then it crashed immediately.

I then opened Event Viewer of windows and viewed Application and it displayed full stacktrace of error. The stacktrace showed relation with Bitmap or images. It was then turned out to be due to app icon not found


I had the same issue. For me it helped to remove the .vs directory in the project folder.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to deployment

error: This is probably not a problem with npm. There is likely additional logging output above Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature) repository element was not specified in the POM inside distributionManagement element or in -DaltDep loymentRepository=id::layout::url parameter "Untrusted App Developer" message when installing enterprise iOS Application How do I copy directories recursively with gulp? How to deploy correctly when using Composer's develop / production switch? Enterprise app deployment doesn't work on iOS 7.1 Can not deserialize instance of java.lang.String out of START_OBJECT token Run command on the Ansible host Error when deploying an artifact in Nexus

Examples related to .net-assembly

No assembly found containing an OwinStartupAttribute Error Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference Could not load file or assembly or one of its dependencies. Access is denied. The issue is random, but after it happens once, it continues System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application How to view the Folder and Files in GAC? How can I get the executing assembly version? How do I find the PublicKeyToken for a particular dll?

Examples related to managed-c++

System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application Could not load file or assembly '***.dll' or one of its dependencies C++/CLI Converting from System::String^ to std::string