SwissQRBill.NET icon indicating copy to clipboard operation
SwissQRBill.NET copied to clipboard

problem using nuget package

Open buluti opened this issue 3 years ago • 13 comments

Hello there, I'm having a problem using the package. {"Could not load file or assembly 'Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2' or one of its dependencies. The system cannot find the file specified.":"Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2"}

It looks like that the <AssemblyVersion>2.4.0.0</AssemblyVersion> in the Core.csproj was not updated

I'm running .Net Standard 2.0 project on the win machine Can you help? Thank you

buluti avatar Aug 19 '22 17:08 buluti

Can you provide more information about your project:

  • On what operating system are you running (Windows, macOS, Linux)?
  • Is it a WPF application, library project, ASP.NET application etc.?
  • Do you use NuGet to include the SwissQRBill.NET library, or have you downloaded the binaries?
  • What version of the SwissQRBill.NET library do you use?
  • Does the error occur at build time or at run-time? If it occurs at run-time, can you provide the full stack trace of the error?
  • What project type do you use (Visual Studio, other tool)? Does it make use of packages.config?
  • Is the SwissQRBill.NET library a direct dependency of the final software, or an indirect dependency (SwissQRBill.NET <- some library <- executable software)?

The file/assembly version is deliberately left at 2.4.0.0 as it would otherwise require binding redirects or recompilation of existing software (if strong naming is used). This is not related to your problem.

manuelbl avatar Aug 21 '22 07:08 manuelbl

Hi Manuel, Thanks for the quick reply. Here is the info:

  • On what operating system are you running (Windows, macOS, Linux)? - Windows
  • Is it a WPF application, library project, ASP.NET application etc.? - Library
  • Do you use NuGet to include the SwissQRBill.NET library, or have you downloaded the binaries? - NuGet
  • What version of the SwissQRBill.NET library do you use? - 3.0.5
  • Does the error occur at build time or at run-time? If it occurs at run-time, can you provide the full stack trace of the error? - at runtime (stack trace is below)
  • What project type do you use (Visual Studio, other tool)? Does it make use of packages.config? - VS 2022, i'm not using packages.config
  • Is the SwissQRBill.NET library a direct dependency of the final software, or an indirect dependency (SwissQRBill.NET <- some library <- executable software)? It is used in the library that is consumed in the main software

Error: {"Could not load file or assembly 'Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2' or one of its dependencies. The system cannot find the file specified.":"Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2"}

Stack trace: at xxxxxxx-ccccccc-mmmmmm.QRCodeService.GenerateSwissQRCode(String invoicenum, Int32 ordernumber, String customerName, String customerZipCode, String customerCity, String customerStreet, String customerHouseNumber, String unstructuredMessage, String billInformation) in C:\xxxxxxx-ccccccc-mmmmmm\SomeOtherService.cs:line 98 at xxxxxxx-ccccccc.SomeServiceService.ReplaceInvoicePlaceholders(String template, PLBox plBox) in C:\xxxxxxx-ccccccc\Services\SomeService\SomeServiceService.cs:line 559 at xxxxxxx-ccccccc.SomeServiceService.GenerateInvoice(PLEnum notification, String language, PLB plb) in C:\xxxxxxx-ccccccc\Services\SomeService\SomeServiceService.cs:line 464 at xxxxxxx-ccccccc.Frontend.Controllers.WebApi.v3.InternalEmailsController.GetInvoiceAttachment(PLEnum notification, String culture, String plId) in C:\xxxxxxx-ccccccc.Frontend\Controllers\WebApi\v3\InternalEmailsController.cs:line 153 at xxxxxxx-ccccccc.Frontend.Controllers.WebApi.v3.InternalEmailsController.PLBegin(SendEmailModel model) in C:\xxxxxxx-ccccccc.Frontend\Controllers\WebApi\v3\InternalEmailsController.cs:line 436

buluti avatar Aug 22 '22 06:08 buluti

It looks like an error in Visual Studio's package dependency management. It has some issues and weaknesses.

  • What kind of project is the final application, a Windows application, ASP.NET application etc.?
  • Is your library project and the project of the final application in the same Visual Studio solution? Or do you create a package from the library, and then add that package to the solution of the final application?
  • Does your library project use other third-party NuGet packages? And if so, do they work?
  • Do you use some form of dynamic library or class loading for the SwissQRBill related code and or the responsible service?

manuelbl avatar Aug 22 '22 07:08 manuelbl

What kind of project is the final application, a Windows application, ASP.NET application etc.? - ASP.NET Is your library project and the project of the final application in the same Visual Studio solution? Or do you create a package from the library, and then add that package to the solution of the final application? - It's in the same solution Does your library project use other third-party NuGet packages? And if so, do they work? - Yes, couple of them and they all work. Do you use some form of dynamic library or class loading for the SwissQRBill related code and or the responsible service? - No

buluti avatar Aug 22 '22 07:08 buluti

I checked the Core.csproj in your code. It seems that the assembly reference is 2.4.0.0. That is the only mention of 2.4.0.0 Could this be the problem?

buluti avatar Aug 22 '22 07:08 buluti

It'll take me some time to reproduce it. In order to do so, I still need more information:

  • What .NET version does the ASP.NET application use?
  • Which NuGet package do you reference in your library project: Codecrete.SwissQRBill.Core, Codecrete.SwissQRBill.Generator, Codecrete.SwissQRBill.Windows or multiple of these?

manuelbl avatar Aug 22 '22 07:08 manuelbl

And the assembly version most likely is not the problem. It's more likely a Visual Studio problem as it has - for whatever reason - decided not to copy the SwissQRBill library (or the QRCodeGenerator library) to the ASP.NET directories.

manuelbl avatar Aug 22 '22 07:08 manuelbl

What .NET version does the ASP.NET application use? - .Net Standard 2.0 Which NuGet package do you reference in your library project: Codecrete.SwissQRBill.Core, Codecrete.SwissQRBill.Generator, Codecrete.SwissQRBill.Windows or multiple of these? - right now I'm using Generator but I have tried with all 3 of them and the result is the same

buluti avatar Aug 22 '22 08:08 buluti

Are your sure the .NET version is .NET Standard 2.0? .NET Standard is just a specification of .NET, not an implementation. It works for library projects, but for an ASP.NET application? (I won't be able to verify it myself until later today.)

manuelbl avatar Aug 22 '22 09:08 manuelbl

There is not .NET Standard for an ASP.NET application. It's either .NET Framework 4.x.x, or .NET 3.1 / 5.0 / 6.0. Which one are you using?

manuelbl avatar Aug 22 '22 21:08 manuelbl

The end application is .Net framework 4.7.2

buluti avatar Aug 23 '22 07:08 buluti

I can reproduce it. As suspected Visual Studio does not copy the assembly Codecrete.SwissQRBill.Core.dll into the bin folder of the main application, be it for a bug or a limitation of the old style project format used for .NET Framework projects.

It's very surprising that QrCodeGenerator.dll, which is a dependency of Codecrete.SwissQRBill.Core.dll, is copied.

The only workaround I'm aware is to add the NuGet package Codecrete.SwissQRBill.Core to both the library project and the ASP.NET project. Other workarounds might exist.

manuelbl avatar Aug 24 '22 18:08 manuelbl

Thank you very much Manuel

buluti avatar Aug 25 '22 09:08 buluti