Unable to load one or more of the requested types - ASP.NET Core 6.0 Web API - asp.net-web-api

ASP.NET Core 6.0 web app. I get an error when I try to map controllers in Startup.cs. The assembly referenced (QESI.Accuracy.Contract) is a project reference, and it works fine.
The line above it loads a class from that project with no issues. This particular assembly is also packaged and used in other solutions, so I'm wondering if something is trying to load the Nuget package instead of the project reference and that is what's causing it to fail.
If I change the name of the assembly for the project to suffix a 2 I get an error that the same type exists in two assemblies. So something somewhere is referencing the version 1.1.58, which would be the nuget package. I've cleared all nuget package caches using these instructions.

Related

Xamarin.Android: System.Runtime.Caching can not resolve reference

I have a solution with:
A project that handles business logic through crud functions. At some point the project uses System.Runtime.Caching
Other webforms, MVC and RESTservice projects. (irrelevant to the topic)
A newly created Xamarins.Forms project targeting .netstandard2.0
My problem is that when I reference the business logic project in the Xamarin.forms project then the Xamarin.Android project errors that it can not resolve the reference System.Runtime.Caching referenced by the business logic project.
It suggests that I add a NuGet package or assembly reference for System.Runtime.Caching, or remove the reference to the business logic project.
I have tried installing the package for both the Xamarin.Forms project and the related Xamarin.Android project. But it does nothing.
I am in a bit of halt here since I am unable to figure what the problem is and better yet how to sovle it.
System.Runtime.Caching doesnt seem to be part of .Net standard hence you can not add it .Check the nuget log when you try to add it.
You might be calling web project/API project code directly from xamarin forms, dont do that. You need to isolate the two.

EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer error

I am trying to port everything from Entity Framework 6.3 to Entity Framework Core 2.1.2 and this is my first experience with EF Core.
I have 2 projects one is my core or infrastructure project with all the entity models, DB Context and repositories and the other one is an asp.Net MVC which is my startup project and using all the services from the core project. Both projects are using .NetStandard Library 2.0.3 and targeted .Net Framework 4.6.2. And I have .Net Core SDK 2.2 on my machine.
The problem:
1- Converted everything to Entity Framework Core (All the entity mappings, contexts and repositories) and all the stuff seems fine, both projects build successfully.
2- starting first migration targeting existing database and entity models. Now while the migration process building both projects I am getting a strange error on asp.net MVC project as following:
An instance of analyzer
Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer
cannot be created from
C:\Users\user\.nuget\packages\microsoft.entityframeworkcore.analyzers\2.1.2\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll
: Could not load file or assembly 'Microsoft.CodeAnalysis,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
3- Now everytime you build the Asp.net project, you get the same error.
I really have no idea about this RawSqlStringInjectionDiagnosticAnalyzer and why this being even used by the projects, I have spent 2 days so far on this problem search all over the Internet, some people experienced somewhat similar problems (like this one) but could not found any solution, some of the stuff that I did was:
Updated my VS to the latest version (15.9.7), no luck
Tried to reference different versions of EF Core including Analyzer for both projects, no luck
I know Microsoft.CodeAnalysis dll should be a VS internal mechanism, nevertheless tried to reference it manually, no luck
Tried to include Microsoft.CodeAnalysis nuget package, no luck
Also there were other packages that I have tried, couldn't remember the names now, no luck
Please help me I am tired of adding and referencing different packages and binaries, I can't even grasp the problem.
I have realized this should be a warning and not an error so I found out that the "Treat warning as error" options in the project settings is enabled so that's reasons I am getting this as an error, however, still do not know the reason behind this warning.

Where could a call to an removed property be cached for WebAPI app?

I have a .NET Web API app that has started failing. The error is that it cannot find the setter of a method: set_QueueLocation on a specific class. That was a property on that class, but was removed. This code lives in a NuGet package that I have control over. I searched both solutions (the Web API one and the library with the class used to have QueueLocation property) and QueueLocation does not occur in either of them.
As I mentioned, the library is a NuGet package and when updating, I didn't update the assembly version (just the NuGet version). I'm thinking that when deploying, it looked at the version and then didn't update it. But I can't find out where that might be cached.
I tried :
%LOCALAPPDATA%\Microsoft\WebsiteCache
%LOCALAPPDATA%\Temp\VWDWebCache
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files.
I'm on VS 2015, Windows 10 pro. Were would this assembly be cached? Or what else might be causing this issue?
Update
This issue is occurring when I run it in debug mode directly from within VS.

"Could not load file or assembly 'XXX.dll' or one of its dependencies. The specified module could not be found

Path of the dlls are in the Path system environment variable.
It works in a C# windows console application and not in IIS 7.5
If I use dependency walker, it complains about some of the DLLS but how does it work in the console application and not in IIS 7.5
Like #Arran said you need to let us know what assembly or assemblies that are throwing the exception.
Since this is an MVC3 project did you make sure to add your deployable dependencies that MVC 3 requires before publishing?
See this article if you haven't Bin Deploy ASP.NET MVC3

MVC3 solution log4net build issue

I have a simple MVC solution with 2 projects, domain and web. There is no real magic in there except that when I build the solution a log4net.dll mysteriously appears in my web project's bin folder. I picked this up after my \Views\Shared\Error.cshtml had a squiggly line below the top line (#model System.Web.Mvc.HandleErrorInfo) saying: "Asp.Net runtime error:Could not load file or assembly log4net.............blah,blah,blah"
I do not have a reference to any log4net in any of my projects, how is the dll getting there? I do not even have anything in my web.config with the word log4net in. This is a MVC3 Framework 4 project.
It's possible that you have installed some NuGet package which depends on log4net. If you don't use NuGet packages maybe you have referenced an assembly which depends on log4net. So when this assembly is loaded the log4net assembly is copied as it is a dependent assembly.

Resources