swharden/FftSharp

**System.TypeLoadException:** 'Could not resolve type with token 010000e0 from typeref (expected class 'FftSharp.FFT' in assembly 'FftSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null')'

tongvietdung opened this issue · 2 comments

Hello,

I've just updated to the latest version 2.0.0 and came across this error. I also used the new code as in the README.md to get the magnitude.

Error Message: System.TypeLoadException: 'Could not resolve type with token 010000e0 from typeref (expected class 'FftSharp.FFT' in assembly 'FftSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null')'

The program breaks at this line from another file before it came to the process of FFT.

AudioService.cs

float[] magnitude = fftService.GetMagnitude(signalBlock); 

FftService.cs

public float[] GetMagnitude(double[] signal)
{
    var windowedSignal = WINDOW.Apply(signal); // WINDOW is Hanning and is created in the constructor.
    var spectrum = FftSharp.FFT.Forward(windowedSignal);
    var magnitude = FftSharp.FFT.Magnitude(spectrum);

    // Convert to float and calculate data loss
    List<float> res = new List<float>();
    foreach (var item in magnitude)
    {
        res.Add((float)item);
    }
    return res.ToArray();
}

Please help me with this. Thank you in advance.

MV10 commented

That error message with a number (010000e0) instead of a valid type name indicates an assembly version conflict. There is either a mismatch between projects in your app, or outside the IDE, a mismatch between what is available at runtime versus what it was compiled against.

Thanks for your answer MV10!

The TypeLoadException with a number token (instead of a type name) usually indicates that the assembly used at runtime is different than the one used at compile time.

Make sure all of your projects are aligned in version, and that you do not have stale ones lying around (do a git clean -xfd, or remove the packages folder, restore the nugets, and make sure there's only one XF version pulled from nuget.org)

source: https://stackoverflow.com/a/42511504