yartat / MP-MediaInfo

Mediaportal MediaInfoLib wrapper
Other
45 stars 21 forks source link

Is it a BUG when create a new instance? - v21.9.3 #44

Open jacksonwj opened 2 years ago

jacksonwj commented 2 years ago

Version 21.9.3

When I new an instance like this

var videoStream = new MediaInfoWrapper(fileName).BestVideoStream;

It will throw an exception

Value cannot be null. (Parameter 'logger')

image

The code in source MediaInfoWrapper.cs

image

Is it a BUG?

yartat commented 2 years ago

Yes. It's a bug

LeaFrock commented 2 years ago

Any progress? Or may I commit a PR?

Cuixq123 commented 1 year ago

i also have this problem

squareballstudios commented 1 year ago

You can get passed this error by using default instances of NullLogger.Instance instances in your constructor.

ILogger _logger = NullLogger.Instance; var media = new MediaInfoWrapper(@"C:\Users\foo\Downloads\06ebb72b-be94-4953-9829-be419eb86f691824599253097493635.mp4",_logger);

All worked as expected...

bpoxy commented 1 year ago

I also have this problem after updating to v21.9.3. I think this is due to the new version of Microsoft.Extensions.Logging.Abstractions enforcing that the instance is not null.

As I see it, there's two possible solutions:

  1. Remove the null default for logger parameter in the constructors.
  2. Null coalesce logger to NullLogger.Instance (similar to @squareballstudios's suggestion).

I, personally, prefer option 2 as it preserves previous behavior.

davepusey commented 1 year ago

Just encountered this issue trying to use the package for the first time. Reverting to version 21.9.2 worked for me.