barnhill / barcodelib

C# Barcode Image Generation Library
Apache License 2.0
733 stars 238 forks source link

Barcodelib stopped working #120

Closed davidkdb closed 3 years ago

davidkdb commented 3 years ago

When trying to run our C#, Framework 4.8 project now, we get this:

image

It was working before. Also tried to update to 2.2.10 with same issue.

All our nugets/references are latest versions, and I suspect the problem for barcodelib is there somewhere.

barnhill commented 3 years ago

I'll take a look.

binki commented 3 years ago

@davidkdb What style of NuGet package references are you using? Do you have packages.config in your project? How did you update to the latest version of BarcodeLib? Are you able to reproduce it in a small solution/project and share that?

davidkdb commented 3 years ago

I use the Manage Nuget Packages (right click on project file).

No packages.config, but app.config.

I always update the Nugets to latest version using Manage Nuget Packages, including Barcodelib.

I suspect that I have updated some NuGet that is not compatible with BarcodeLib.

It's not possible to create a small project because I have references to internal dlls, and it would be difficult anyways to reproduce the settings in this project.

But maybe there is a way for you to see which nugets we are using, and maybe find out something there ?

binki commented 3 years ago

I use the Manage Nuget Packages (right click on project file).

No packages.config, but app.config.

Good. packages.config is the old way of doing NuGet. Not having it probably means you’re using <PackageReference/> which should generally have fewer issues.

I always update the Nugets to latest version using Manage Nuget Packages, including Barcodelib.

I suspect that I have updated some NuGet that is not compatible with BarcodeLib.

It's not possible to create a small project because I have references to internal dlls, and it would be difficult anyways to reproduce the settings in this project.

It is difficult, but without this, we might not be able to help you. You or one of your colleagues with access to the project may be the only people able to track down and identify the problem.

Based on googling, this might be intended behavior. Is this exception actually thrown and not caught? Did you turn on first-chance exceptions (or disable Just My Code, etc.,—I don’t know what things in the Visual Studio debugger are called because I don’t touch those settings much)? If the exception isn’t actually being thrown out of the call to Barcode.Encode(), then there’s no reason for you to care that it is being thrown at all: https://stackoverflow.com/a/1224278 .

If you run the program outside of the debugger, what exception is thrown?

davidkdb commented 3 years ago

Good news!

You were right. By using a try/catch around it it worked. And I ignored the error in the IDE.

But anyways this has changed, and you should keep it in mind. It was not throwing an exception before.

davidkdb commented 3 years ago

I looked at the link. It would be much better if you handled this in your code, so it doesnt produce any errors pack to calling program.

binki commented 3 years ago

You shouldn’t need to have a try{}catch{} around that. The point is that people think this exception is thrown and handled in MS’s code, so there’s nothing for us to catch. It’s just that your debugger settings are causing you to see the exception because your debugger is set to exceptions even if they’re handled.

Is there a different exception being thrown which you are trying to debug? If the debugger stops there and you press “Resume”, does it throw a different exception? What are you trying to debug? Does it really not happen for you if you create a new project with the minimal code—most of the Visual Studio debugging settings like this are global.