TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

[Question]: FileLoadException OneOf.dll

Open FrancescoRusticali opened this issue 1 year ago • 10 comments

Description

Hi all, I'm having some issues trying to compile and run the current master branch. I get a FileLoadException while trying to do anything that needs to call OneOf.dll. This is the error:

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

For example I get it while calling keras.Input.

Anyone having the same issue?

Alternatives

No response

FrancescoRusticali avatar Apr 27 '23 16:04 FrancescoRusticali

Hi, did you open some settings in VS that enables strongly-name signature automatically? And what if uninstalling Oneof and installing it again?

AsakusaRinne avatar Apr 27 '23 19:04 AsakusaRinne

Hi, I tried to uninstall and install OneOf, but I still get the error. Calling OneOf directly from my code works fine, the problems seems to arise when calling Tensorflow methods that use OneOf. I think this should be related to Tensorflow being signed, while OneOf is not. This comes from the csproj file:

    <Reference Include="OneOf, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\OneOf.3.0.243\lib\net45\OneOf.dll</HintPath>
    </Reference>
    <Reference Include="Tensorflow.Binding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\TensorFlow.NET.1.0.0\lib\netstandard2.0\Tensorflow.Binding.dll</HintPath>
    </Reference>
    <Reference Include="Tensorflow.Keras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\TensorFlow.Keras.1.0.0\lib\netstandard2.0\Tensorflow.Keras.dll</HintPath>
    </Reference>

FrancescoRusticali avatar Apr 28 '23 07:04 FrancescoRusticali

To give more info: this seems to be a general problem with unsigned thirt party dlls. I get similar error in version 0.100.4 related to HDF5CSharp.dll trying to save model weights in h5 format with save_weights. HDF5CSharp also is not signed:

    <Reference Include="HDF.PInvoke.1.10, Version=1.10.612.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\HDF.PInvoke.1.10.1.10.612\lib\netstandard2.0\HDF.PInvoke.1.10.dll</HintPath>
    </Reference>
    <Reference Include="HDF5CSharp, Version=1.17.0.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\HDF5-CSharp.1.17.0\lib\netstandard2.0\HDF5CSharp.dll</HintPath>
    </Reference>

I also found #915 that seems related to that. It's closed as resolved, but I don't understand how. Is there any workaround?

FrancescoRusticali avatar Apr 28 '23 07:04 FrancescoRusticali

Here may be a possible work around https://stackoverflow.com/questions/290980/error-a-strongly-named-assembly-is-required. BTW, do you build from source yourself because you want to use the latest master code, or you want to customize tf.net for your project? If you just want to use master branch code, maybe we can add an automatic workflow to make nightly releases on myget. Besides, does the error appeared on your PC when using v0.100.4 or other release of tf.net?

AsakusaRinne avatar Apr 28 '23 12:04 AsakusaRinne

Thank you for the suggestion. From the stackoverflow link, a possible workaround can indeed be to build master source code without the "sign" flag.

BTW, do you build from source yourself because you want to use the latest master code, or you want to customize tf.net for your project?

No, I just would like to use latest master code. Nightly releases would be great!

Besides, does the error appeared on your PC when using v0.100.4 or other release of tf.net?

The error about OneOf appeared on my pc only with latest master code, but the OneOf dependency was not there in v0.100.4. Instead, the error about HDF5CSharp appeared on my PC also with v0.100.4, installed with nuget.

FrancescoRusticali avatar Apr 28 '23 13:04 FrancescoRusticali

Version v0.100.5 has come out and we also added nightly release, which is available by adding https://www.myget.org/F/scisharp/api/v3/index.json to your nuget source. Could you please have a try with v0.100.5?

AsakusaRinne avatar May 07 '23 18:05 AsakusaRinne

Version v0.100.5 has come out and we also added nightly release, which is available by adding https://www.myget.org/F/scisharp/api/v3/index.json to your nuget source. Could you please have a try with v0.100.5?

I have the same issue with v0.100.5 and only with .NET 4.8 (no problem with .NET 6):

image

Superpiffer avatar May 11 '23 10:05 Superpiffer

It's because tf.net signs the assembly while Oneof does not. I've submitted an issue to Oneof. I think we should give up Oneof before the next release if it won't be signed.

AsakusaRinne avatar May 11 '23 14:05 AsakusaRinne

Maybe you can try installing the package OneOf https://github.com/mcintyre321/OneOf

CAMB-dev avatar May 11 '23 15:05 CAMB-dev

It's because tf.net signs the assembly while Oneof does not. I've submitted an issue to Oneof. I think we should give up Oneof before the next release if it won't be signed.

Any news about this issue? New incoming version still has OneOf as a dependency.

Superpiffer avatar Jun 22 '23 14:06 Superpiffer