Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReflectionTypeLoadException when running audio2csv #241

Closed
tinchobulen opened this issue Jun 24, 2019 · 19 comments · Fixed by #244 or #255
Closed

ReflectionTypeLoadException when running audio2csv #241

tinchobulen opened this issue Jun 24, 2019 · 19 comments · Fixed by #244 or #255
Assignees
Labels

Comments

@tinchobulen
Copy link

tinchobulen commented Jun 24, 2019

Describe the bug

AnalysisPrograms.exe does not run. I tried using R and Power Shell but did not succed

Expected behavior

To analyze a long recording of 1.1 hours in .wav format.

Diagnostics

  • I Confirm I have followed the instructions for reporting a bug
  • I have attached a log
  • I have answered the following questions:
    • Operating system: Windows 7 Ultimate
    • AP.exe version: v19.5.0.1
    • The data used can be found:
    • The command I used:

in Power Shell:

D:\AP\AnalysisPrograms.exe audio2csv D:\Tesis\DatosSitiosCalilegua\AP_analysis\Mixdown1.1hs.wav Towsey.Acoustic.yml D:\Tesis\DatosSitiosCalilegua\results_AP.exe

In R:

# The directory to store the results

base_output_directory <- "D:/Tesis/DatosSitios Calilegua/results_AP.exe"

# Get a list of audio files inside the directory
# (Get-ChildItem is just like ls, or dir)

files <- list.files(directory, pattern = ".wav", full.names = TRUE)


# iterate through each file
for(file in files) {
  message("Processing ", file) 
  
  # get just the name of the file
  file_name <- basename(file)
  
  # make a folder for results
  output_directory <- normalizePath(file.path(base_output_directory, file_name))
  dir.create(output_directory, recursive = TRUE)
  
  # prepare command
  command <- sprintf('audio2csv --log-level 7 "%s" "Towsey.Acoustic.yml" "%s"', file, output_directory)
  
  # finally, execute the command
  system2('D:/AP/AnalysisPrograms.exe', command)
}
  • The config file I used: Towsey.Acoustic.yml

Screenshots

PowerShell:
image

Rstudio:

image

image

Additional Details

Add any other context about the problem here.

@tinchobulen
Copy link
Author

ap_files.txt

@atruskie
Copy link
Member

atruskie commented Jun 25, 2019

Thanks for the report 😄 !

There are two separate bugs here.

1

The PowerShell screenshot shows a problem probably located to your locale. What country are you located in? Do you use a comma or a period (a decimal point) to separate the integer and fractional parts of a number?

Can you please attach a verbose log for that case?

2

For the main problem, where it is failing to load the required libraries, that's a pickle. I'm almost certain it is something to do with your computer. I'm going to make a custom build of AP.exe that will output more information to help us debug this.

@tinchobulen
Copy link
Author

  1. I'm in Argentina. I use comma to separate the the integer from fractional parts of a number.

Please find attached the very verbose log file:

log_20190625T130137Z.txt

cheers,

Martin.

atruskie added a commit that referenced this issue Jun 26, 2019
If there is a ReflectionTypeLoadException there currently is no way to understand what error actually occurred.

Adds better error output.

Speculatively addresses #241
@atruskie atruskie self-assigned this Jun 26, 2019
@atruskie
Copy link
Member

Hi @tinchobulen,

I've created a special build of AP.exe that will provide more information about the error. Can you please download it from here https://ci.appveyor.com/api/buildjobs/91ikkc1ailtlhih3/artifacts/src%2FAnalysisPrograms%2Fbin%2FDebug.19.6.1.1.zip and make sure that version is being used in your R script.

@tinchobulen
Copy link
Author

Hi @atruskie thank you very much for your help!
I tried again to run AP with this species debug version. It still doesn't work. I checked for decimals and commas errors.
I tried in my Power Shell and R.

please find attached the log file from R script:
log_20190701T134859Z.txt

log file from Power Shell script.

log_20190701T133717Z.txt

It creates 2 folders in my output direction. One named: Mixdown.wav (inside is the log file .txt and a .yml file names Towsey.Acoustic) and another names Towsey.Acoustic (empty inside)

thank you again for your help!

cheers,

Martín

@atruskie
Copy link
Member

atruskie commented Jul 1, 2019

Hi @tinchobulen,

I've fixed the comma error (problem number 1) in #242. You'll see this fix in the weekly release version soon.

The other problem, due to some missing files, we're dealing with here. Note: the fixes are in separate branches, and won't both be included in one version until they are both fixed.

Also, it seems you used an older version of AP.exe. I am not sure what is causing the missing code problem, so the special build I linked to above contains extra code that will tell me about the problem. But it isn't fixed yet. Unless you use that version they're won't be any difference in outcome. From the log files you attached:

2019-07-01T10:48:59.8644133-03:00 [1] INFO  CleanLogger - QUT Ecoacoustics Analysis Programs - version 19.5.0.1 (DEBUG build, 2019-05-05T14:00:56.6341125Z)

See how the version number is 19.5.0.1 and not 19.6.1.1?

Please try downloading the linked version again. Make sure to delete any old versions of AP.exe. Then try to run again, with verbose logging, and attach logs.

Thanks!

@atruskie
Copy link
Member

atruskie commented Jul 1, 2019

From @tinchobulen:

Sure @atruskie! sorry for that.

please find attached the log file from the new version of AP.exe.

Tried with R.

log_20190701T150843Z.txt

Martín.

The important part of the log is thus part:

Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I totally did not expect that 😮. I'll look into a fix.

@atruskie atruskie added the bug label Jul 2, 2019
@atruskie atruskie changed the title AP FC spectrogram ReflectionTypeLoadException when running audio2csv Jul 2, 2019
atruskie added a commit that referenced this issue Jul 4, 2019
Fixes #241

Due to some complicated diamond dependency problems I do not really understand, there was a conflict with the version of System.Numerics.Vectors. ImageSharp required a version shipped only in .NET Standard, which we did not have access to.

The only solution I could find was to move to the larest dev build of ImageSharp, which changed this dependency.

This change includes app binding redirects, ImageSharp API updates, and a few tweaks to the reflection type load exception formatter so that it now outputs fusion logs.

Still need to check that tests pass.
@atruskie
Copy link
Member

atruskie commented Jul 4, 2019

Hi @tinchobulen,

I think I have fixed the problem. Unfortunately, I could never replicate the problem on my computers or servers. That means you'll need to test it for me again 😄

As before, please download this https://ci.appveyor.com/api/buildjobs/a9siwupb28my3bnk/artifacts/src%2FAnalysisPrograms%2Fbin%2FRelease.19.7.0.3.zip test version of AP.exe. It has the version number 19.7.0.3. Make sure you delete the old version. Run it in R again and let me know if it works. If it fails, please attach a log.

Thanks!

@tinchobulen
Copy link
Author

tinchobulen commented Jul 5, 2019

Hello @atruskie

I tried in my computer and unfortunately it didn't work :(

Maybe its something wrong with my installation process?
I re updated my .NET windows.
please find attached the log file and a screenshot from my R console.

log_20190705T140148Z.txt

5-7-2019 11 7 10 1

thank you!!

@tinchobulen
Copy link
Author

Or maybe its a problem with my windows 7 ultimate version?

I will try it in another computer.

cheers,

Martin.

@atruskie
Copy link
Member

atruskie commented Jul 5, 2019

Hi @tinchobulen,

So yeah I'm pretty confident it is something unique about your machine. I'm just not sure what it is. It is worth fixing because it might be a condition shared by more than one computer... Or it could equally be isolated to your machine.

The core problem seems to be around a missing dependency that should be installed with the .NET Framework.

Can I get you to tell me which .Net framework you have installed? https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

Also it would be great to try it on another computer.

And after you've got the version, try installing a newer .NET Framework. Our goal was to be backwards compatible but it looks like I might have messed that up. https://www.microsoft.com/en-us/download/details.aspx?id=55170

Thanks again,

@tinchobulen
Copy link
Author

tinchobulen commented Jul 8, 2019 via email

@tinchobulen
Copy link
Author

Hello @atruskie !

I want to let you know that finally I ran the audio2csv command!
I'me really excited about this :) I just tried out with a simple 1 hour recording file.
I think the problem was isolated in my computer. Don't know yet the origin. Perhaps its about the administrators permits on my windows notebook. Nevertheless, I made it on my girlfriend's notebook.

please find attached the log file (very_verbose enabled)

Also, at the end of the analysis a new error pups out, when trying to make an Events CSV file. Anyway I think I have a progress here!

thank you for your help.

log_20190713T160526Z.txt

now I will start to analyze longer recordings.

cheers,

Martín

@atruskie
Copy link
Member

Hi @tinchobulen,

Glad it's working. If you ever track down the problem please let me know. I'll close this issue for now.
I'm fairly confident this problem will disappear on a new install of your OS, or if you upgrade to Windows 10.

The event file error you are referring to is not an error. Our analyses can return acoustic events, or acoustic indices, or both. Since you ran an analysis that only generates indices, AP warned you that you won't find an Events.csv file in your output folder (just in case you were expecting it).

Thanks for working with me on this. If you have any more problems, please contact us again.

atruskie added a commit that referenced this issue Jul 15, 2019
…s better errors for reflection loading exceptions (#244)

* Better formats reflection exceptions

If there is a ReflectionTypeLoadException there currently is no way to understand what error actually occurred.

Adds better error output.

Speculatively addresses #241

* Bumped System.Numerics.Vectors and ImageSharp

Fixes #241

Due to some complicated diamond dependency problems I do not really understand, there was a conflict with the version of System.Numerics.Vectors. ImageSharp required a version shipped only in .NET Standard, which we did not have access to.

The only solution I could find was to move to the larest dev build of ImageSharp, which changed this dependency.

This change includes app binding redirects, ImageSharp API updates, and a few tweaks to the reflection type load exception formatter so that it now outputs fusion logs.

Still need to check that tests pass.

* Fix missing SixLabors myget reference
@atruskie
Copy link
Member

atruskie commented Sep 9, 2019

It turns out one of our team members (@ninascarpelli) just encountered this problem!

@ninascarpelli can you please use the following link and report back on which version of .NET is installed on your computer? https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

@atruskie atruskie reopened this Sep 9, 2019
@ninascarpelli
Copy link
Contributor

Hi @atruskie

I've got .NET Framework 4.7.2 (QUT desktop) and 4.8 (personal laptop) and both are giving me the same error.

@tinchobulen
Copy link
Author

Hi!

thanks for sharing this with me.

I'll be on alert for news about this bug.

cheers.

@ninascarpelli
Copy link
Contributor

R is writing the command like this:

C:\AP\ANALYS~1.EXE audio2csv "C:/AP/AudioData/REC05_WA/20190815_070035.WAV" "C:/AP/ConfigFiles/Towsey.Acoustic.yml" "C:/AP/outputs//REC05_WA/20190815_070035.WAV" -p

and this is causing the failure.

@atruskie
Copy link
Member

I've narrowed this down further:

Situation Works Notes
R system2 Uses sys.which to shorten exe name to C:\AP\ANALYS~1.EXE
R shell Uses cmd to shell execute
cmd (8.3 name) C:\AP\ANALYS~1.EXE
cmd (full name)
PowerShell 5 (8.3 name) C:\AP\ANALYS~1.EXE
PowerShell 5 (full name)
PowerShell 6 (8.3 name) C:\AP\ANALYS~1.EXE
PowerShell 6 (full name)

These attributes do not seem to change, the outcome:

  • Whether or not it is run as an Administrator
  • Whether or not the files are unblocked

atruskie added a commit that referenced this issue Sep 10, 2019
atruskie added a commit that referenced this issue Sep 11, 2019
Fixes #241

When R executes AP.exe it uses the `Sys.which` function to resolve the executable
name. This function uses the Windows 8.3 short-name functionality by defualt which
launches the application as ANALYS~1.exe. Since the application is no longer named
correctly, the AnalysisPrograms.exe.config file cannot be loaded and all of our
application binding redirects are ignored. Subsequently the fusion assembly loader
throws errors like:

```
  System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
	- Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

```

In addition to the stack overflow post that should how to update the current domain's
App.Config file and settings, I also had to force Fusion to redo it's setup. This method,
is to say the least, fragile, and we can expect it to fail in the port to .NET Core.

Additionally added a AP_DEFAULT_LOG_VERBOSITY flag that set the log level verbosity
before the command line is parsed.

Additionally added a few extension method helpers and associated tests
atruskie added a commit that referenced this issue Feb 10, 2020
Speculatively fixes #279.

The fix from #241 should not be needed on Mono (and in fact cannot work at all in its current form!).
atruskie added a commit that referenced this issue Feb 19, 2020
- defined common props in Directory.Build.props
- removed dependancy on .NET Framework and MSBuild Community Tasks and replaced git versioning tasks with a powershell script.
- locked .net core to stable release in global.json to avoid a bug with FSharp project SDK not being able to parse a nuget version
- Reinstalled stylecop project reference into all projects
- renabled deterministic builds on FSharp projects by chaning output type to PDB
- Disabled short name tests because I could not determine any valid test or faulting case that still occurs (see #241)
- Removed vagrant file - soon will not be necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment