0

I have this solution that consists of multiple projects (one is a class library and other is the web project, which is MVC. However, when trying to run the web project in Debug, I get the "Could not load file or assembly..." error.

Assembly Reference Error

I have the NuGet package references installed in the class library and the class library is referenced by the web project. So, I have no idea why this error is generating when the references are clearly included in the class library.

Class library Nuget Package References

I would like to how if anyone knows how to resolve this? It doesn't make sense to include the NuGet package in both the class library and the web application.

ArunPratap
  • 4,020
  • 7
  • 22
  • 39
Hashan JXT
  • 21
  • 3
  • Possible duplicate of [Could not load file or assembly or one of its dependencies](https://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies) – Niranjan Singh Apr 16 '19 at 04:31
  • Hi Hashan, please right click the solution name and clean, delete the bin and obj folder to build. Checking if the "Copy to Local" property for the reference AWSSDK.SQS is set to true and the specific version is set to true, Right click the project name-properties-Build and platform target should be ‘Any CPU’. If this issue persists, please have a test directly add this reference under this web application, it can help us confirm the reference version is right and not the reason that caused this issue. – Sara Liu - MSFT Apr 17 '19 at 08:06
  • @SaraLiu-MSFT Thank you for your comment. I have tried your first suggestion and I cannot still resolve this issue. Therefore, I tried adding the SQS reference to the web project manually using the NuGet (same version as the class library as you mentioned). When I did this it worked. Therefore, I am a bit confused about why I need to add the package to both class library and web project. Any ideas? – Hashan JXT Apr 24 '19 at 05:19
  • @SaraLiu-MSFT Also, let me add a bit more details about this issue, so it may aid you to help me find a solution. In my current visual studio solution, I have a class library which is in .NET Standard 2.0 and it consists of the SQS .dll from Nuget. Then my web (MVC) project is based on .NET framework 4.7.1 and it references the class library. Therefore, I was wondering whether this has anything to do with it? – Hashan JXT Apr 24 '19 at 05:19
  • @HashanJXT, thanks for your update, have you directly use or invoke some features inside the AWSSDK.SQS.dll in the class library? If not, you can have a try with it, directly use this dll inside the class library will make the dll be copied into the MVC web application, please have a look at this: the https://stackoverflow.com/questions/1132243/msbuild-doesnt-copy-references-dll-files-if-using-project-dependencies-in-sol – Sara Liu - MSFT Apr 24 '19 at 07:27

1 Answers1

1

This is same as previously asked on stackoverflow. Please find the link

This is issue is like your awssdk.sqs dll version mismatch.

  • Thank you for your comment. Unfortunately, my issue doesn't seem to be related to the article that you have mentioned. However, I am wondering whether I need to include the awssdk.sqs.dll in both class library and web project? if so, why? Shouldn't the web project retrieve the .dll from the class library? Because it doesn't make sense in including an SDK in both class library and the web project. – Hashan JXT Apr 24 '19 at 04:04
  • I don't know my understanding is correct or not, but you need to add the .dll in both library. That is needed as you can inject these different class library project independently. The second answer for you web project -> You no need to add this .dll in web project unless you used any functionality from this awssdk.sqs.dll. – Shivaji Kokate May 16 '19 at 15:22