c# version=1.0.0.0 - Could not load file or assembly or one of its dependencies



culture=neutral publickeytoken=null (25)

My solution for .NET 4.0, using Enterprise Library 5, was to add a reference to:

Microsoft.Practices.Unity.Interception.dll

I'm having another of these "Could not load file or assembly or one of its dependencies" problems.

Additional information: Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have no idea what is causing this or how I could debug it to find the cause.

I've done a search in my solution catalogs .csproj files, and every where I have Unity I have:

Reference Include="Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"

Can't find any reference anywhere which goes against 1.2.0.0 in any of my projects.

Any ideas how I should go about solving this?

I would also appreciate tips on how to debug problems like this in general.


Thanks Riddhi M. Following worked for me.

Remove Temporary Files C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files Close VSTS and Open Again Remove and Add the same DLLs (Note: you add the same matching versions)


In solution explorer right click on project (not solution), in build tab choose Platform target : "Any CPU".


I had similar problem. **Juntos answer is correct ** but you should note one important tip!

For unity 2.1.505.2 different AssemblyVersion and AssemblyFileVersion are specified:

AssemblyFileVersion is used by nuget but CLR does not care about it! CLR is going to use only AssemblyVersion!

So redirects should be applied to a version specified in AssemblyVersion: 2.1.505.0

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.505.0" newVersion="2.1.505.0" />
</dependentAssembly>
</assemblyBinding>

See also: What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?


Another possible cause: make sure you haven't accidentally given both of the projects the same assembly name in project properties.


Microsoft Enterprise Library (referenced by .NetTiers) was our problem, which was in turn referencing an older version of Unity. In order to solve the problem we used the following binding redirection in the web.config:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Alternatively, you may want to just update the Enterprise Library to the latest version.


Following worked for me.

  • Remove Temporary Files C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
    • then right click on Temporary Asp.net Files>properties>security and give total control access to IIS and to all user runing my project

I "Set as Startup Project" the unloaded/unfound library/project.

Then deployed it.

It worked!

I think it couldn't found the .dll because it was not in the assembly at first.


You have to delete Your appname.dll file from your output folder. Cleanup Debug and Release folders. Rebuild and copy to output folder regenerated dll file.


Check the Web.config/App.config file in your project. See if the version numbers are correct.

<bindingRedirect oldVersion="X.X.X.X-X.X.X.X" newVersion="X.X.X.X" />

This worked for me.


Not sure if this might help.

Check that the Assembly name and the Default namespace in the Properies in your asemblies match. This resolved my issue which yielded the same error.


  • Goto :Solution -> Package
  • Click on Advanced Tab (Find below the page)
  • Add your dll to additional assemblies(this way we can add external dlls in sharepoint).

This issue happened to me where one of my dependent libraries was compiling a DLL with "Any CPU" when the parent library was expecting a compilation of "x64".


if you are getting this error message by opening an application on you windows xp it mean first you have installed that app due to its not working without net framework 4 and service pack 3 . you installed both and again you are getting this error so you should reinstall that app again but first uninstall from add and remove

if this not work please dont abuse me . i am also a junior


At 99% the Could not load file or assembly or one of its dependencies problem is caused by dependencies! I suggest you follow this steps:

  1. Download Dependency Walker from http://www.dependencywalker.com/

  2. Launch Dependency Walker and open the dll (in my case NativeInterfaces.dll)

  3. You can see one or more dll with the error in red Error opening file...

  4. It means that this dll is missing in your system; in my case the dll name is MSVCR71.DLL

  5. You can download missings dll from google and copy in right path (in my case c:\windows\system32)

  6. At this point, you must register the new dll in the GAC (Global Assembly Cache): open a DOS terminal and write:

    cd \Windows\System32
    regsvr32 /i msvcr71.dll
    
  7. Restart your application!


Try checking if the "Copy to Local" property for the reference is set to true and the specific version is set to true. This is relevant for applications in Visual Studio.


In my case, none of the proposed answer worked.

Here is what worked for me:

  1. Remove the reference
  2. Rename the DLL
  3. Import the reference again

The second step was important apparently as it did not work without it.


I had this today, and in my case the issue was very odd:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.1.0" newVersion="3.1.0.0" />
  </dependentAssembly>0.

Note the stray characters at the end of the XML - somehow those had been moved from the version number to the end of this block of XML!

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
  </dependentAssembly>

Changed to the above and voila! Everything worked again.


For me, none of the other solutions worked (including the clean/rebuild strategy). I found another workaround solution which is to close and re-open Visual Studio.

I guess this forces Visual Studio to re-load the solution and all the projects, rechecking the dependencies in the process.


  1. Check if you are referencing an assembly which in turn referencing an old version of unity. For example let's say you have an assembly called ServiceLocator.dll which needs an old version of Unity assembly, now when you reference the ServiceLocator you should provide it with the old version of Unity, and that makes the problem.

  2. May be the output folder where all projects build their assemblies, has an old version of unity.

You can use FusLogVw to find out who is loading the old assemblies, just define a path for the log, and run your solution, then check (in FusLogvw) the first line where the Unity assembly is loaded, double click it and see the calling assembly, and here you go.


For me rebuilding the unity game without Unity C# Proects Checkmark worked.


In my case in the bin folder was a non reference dll called Unity.MVC3 , i tried to search any reference to this in visual studio without success, so my solution was so easy as delete that dll from the bin folder.


I also got this terrible error and found a solution for this...

  1. Right Click on the Solution name
  2. Click Clean Solution
  3. Restart Visual Studio
  4. Goto project Properties >> Build
  5. Change Configuration to Release
  6. Start Debugging (F5)

1) , 2)

4) , 5)

Hope this will help you also.


Open IIS Manager

Select Application Pools

then select the pool you are using

go to advanced settings (at right side)

Change the flag of Enable 32-bit application false to true.


First of all I got this in VS2017 with an old project I needed to make a tiny change to and upraded all the projects to framework 4.7.


Several others have mentioned selecting Any CPU can fix this issue.

There's a couple places you need to do it, and it might not just be as simple as selecting from the dropdown. This fixed it for me:

1) You need to do it both here:

2) And also in Configuration Manager (right click on solution)

But what if it isn't there???

Then click New and choose these settings: (thanks @RckLN)





c# .net reference compiler-errors