Asp.net web api 运行ASP.NET web api时无法加载文件或程序集错误

Asp.net web api 运行ASP.NET web api时无法加载文件或程序集错误,asp.net-web-api,xamarin.forms,Asp.net Web Api,Xamarin.forms,我正在用VS2019开发一个带有ASP.NET Web Api的Xamarin.Forms应用程序 不知怎的,当我运行WebAPI项目时,我发现了这个错误 Xamarin.Forms.Xaml,它在我的web api中没有引用 无法加载文件或程序集“Xamarin.Forms.Xaml,Version=2.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件。 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有

我正在用VS2019开发一个带有ASP.NET Web Api的Xamarin.Forms应用程序

不知怎的,当我运行WebAPI项目时,我发现了这个错误 Xamarin.Forms.Xaml,它在我的web api中没有引用

无法加载文件或程序集“Xamarin.Forms.Xaml,Version=2.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件。 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源

异常详细信息:System.IO.FileNotFoundException:无法加载文件或程序集“Xamarin.Forms.Xaml,版本=2.0.0.0,区域性=中性,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件

源错误:

在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别

程序集加载跟踪:以下信息有助于确定无法加载程序集“Xamarin.Forms.Xaml,Version=2.0.0.0,Culture=neutral,PublicKeyToken=null”的原因

==预绑定状态信息=== 日志:DisplayName=Xamarin.Forms.Xaml,版本=2.0.0.0,区域性=neutral,PublicKeyToken=null (详细说明) 日志:Appbase=file:///C:/Users/Malcolm/Documents/Visual 2019工作室/项目/LakesLinenOrdersApp/LakesLinenOrdersApi/ 日志:Initial PrivatePath=C:\Users\Malcolm\Documents\Visual Studio 2019\Projects\LakesLinenOrdersApp\LakesLinenOrdersApi\bin 调用程序集:GUI,版本=1.0.0.0,区域性=中立,PublicKeyToken=null

这是堆栈跟踪:

[FileNotFoundException:无法加载文件或程序集'Xamarin.Forms.Xaml,版本=2.0.0.0,区域性=中性,PublicKeyToken=null'或其依赖项之一。系统找不到指定的文件。] System.ModuleHandle.ResolveType(RuntimeModule模块、Int32 typeToken、IntPtr*typeInstArgs、Int32 typeInstCount、IntPtr*methodInstArgs、Int32 methodInstCount、ObjectHandleOnStack类型)+0 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule模块、Int32 typeToken、RuntimeTypeHandle[]类型实例化上下文、RuntimeTypeHandle[]方法实例化上下文)+151 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,类型[]genericTypeArguments,类型[]genericMethodArguments)+135 System.Reflection.CustomAttribute.FilterCustomAttributeCord(CustomAttributeRecord caRecord,MetadataImport作用域,Assembly&LastAptCookAssembly,RuntimeModule decoratedModule,MetadataToken decoratedToken,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object[]属性、IList-derivedAttributes、RuntimeType和attributeType、IRontimeMethodInfo和ctor、Boolean和ctorHasParameters、Boolean和isVarArg)+92 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule、Int32 decoratedMetadataToken、Int32 pcaCount、RuntimeType attributeFilterType、Boolean mustBeInheritable、IList derivedAttributes、Boolean isDecoratedTargetSecurityTransparent)+502 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly程序集,RuntimeType caType)+108 System.Reflection.RuntimeAssembly.GetCustomAttributes(布尔继承)+40 Owin.Loader.DefaultLoader.SearchForStartupAttribute(字符串friendlyName,IList
1错误,布尔值和冲突)+106
Owin.Loader.DefaultLoader.GetDefaultConfiguration(字符串friendlyName,IList
1错误)+46 Owin.Loader.DefaultLoader.LoadImplementation(字符串startupName,IList
1 errorDetails)+75
Owin.Loader.DefaultLoader.Load(字符串startupName,IList
1 errorDetails)+21 Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup()+115 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint()+28 System.Threading.LazyInitializer.EnsureInitializedCore(T&target,Boolean&initialized,Object&syncLock,Func`1 valueFactory)+119 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication上下文)+106 System.Web.HttpApplication.registereventsubscriptionswithis(IntPtr-appContext,HttpContext-context,MethodInfo[]handlers)+552 System.Web.HttpApplication.InitSpecial(HttpApplicationState,MethodInfo[]处理程序,IntPtr-appContext,HttpContext-context)+181 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr-appContext,HttpContext-context)+228 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)+314

[HttpException(0x80004005):无法加载文件或程序集'Xamarin.Forms.Xaml,版本=2.0.0.0,区域性=中性,PublicKeyToken=null'或其依赖项之一。系统找不到指定的文件。] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+10085052 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequestWR,HttpContext上下文)+263它有哪些引用?例如,它是否引用了另一个确实引用了Xamarin表单的项目?不,我看不到。我试图从解决方案中删除web api项目,但当我双击web api项目文件时,它仍在打开它曾经所在的解决方案。为什么?这是因为web api项目文件仍然与解决方案位于同一文件夹中。您应该检查web api项目的引用。您可以尝试将web api项目文件复制到另一个新文件夹,然后再次打开它。