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

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

Open
jacksonwj opened this issue Oct 17, 2022 · 6 comments
Open

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

jacksonwj opened this issue Oct 17, 2022 · 6 comments
Labels

Comments

@jacksonwj
Copy link

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
Copy link
Owner

yartat commented Oct 17, 2022

Yes. It's a bug

@yartat yartat added the bug label Oct 17, 2022
@LeaFrock
Copy link

Any progress? Or may I commit a PR?

@Cuixq123
Copy link

Cuixq123 commented Dec 6, 2022

i also have this problem

@squareballstudios
Copy link

squareballstudios commented Dec 11, 2022

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
Copy link
Contributor

bpoxy commented Mar 3, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants