StephenCleary / AsyncEx

A helper library for async/await.
MIT License
3.49k stars 358 forks source link

Installed aseemnbly Nito.AsyncEx.Coordination, Version=5.1.2.0 but shows Could not load IO error #249

Closed anupshah2it closed 2 years ago

anupshah2it commented 2 years ago

I am running a unit test and it seems both projects I have updated the below assembly to the latest version but it keeps throwing this error. And I am surprised that only running below the line is throwing that error it has to do something with assembly?

    Numbers = new Pool<Number>(5, i => new Number(i)); // This is the line to be executed but throws below exception

    public Pool(int poolCount, Func<int, T> factory, int takeItemTimeout = 30000) // This is the method to get in

Stacktrace:

System.IO.FileLoadException: 'Could not load file or assembly 'Nito.AsyncEx.Coordination, Version=5.1.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)'

In the project file, it is referenced as below, no public key (I am not sure but sharing for reference)

 <Reference Include="Nito.AsyncEx.Coordination, Version=5.1.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Nito.AsyncEx.Coordination.5.1.2\lib\net461\Nito.AsyncEx.Coordination.dll</HintPath>
    </Reference>

I tried many ways but it keeps throwing errors, from another project it is running well but only this at this line it throws the error, please suggest getting out of this situation.

anupshah2it commented 2 years ago

The problem was with Nito assembly it was not strongly typed hence. I even updated the packages but no help so added StrongNamer NuGet package and it resolved the issue, able to run the code now.

Please share if you have any other way of working solution.

StephenCleary commented 2 years ago

Nito doesn't support strong naming because strong naming causes so many issues. The suggested workaround (for now) is to use StrongNamer.