ASP .NET CORE 找不到带有自定义程序集的文件或程序集 [英] ASP .NET CORE could not find file or assembly with custom assembly

查看:58
本文介绍了ASP .NET CORE 找不到带有自定义程序集的文件或程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题.

I've ran into a weird problem.

我基本上有自己的 .NET-core 网络堆栈,我已将其内置到几个 .dll 中,我想从另一个 ASP CORE 解决方案中引用这些.

I basically have my own web-stack for .NET-core which I've built into a few .dlls, and I want to reference these from another ASP CORE-solution.

VS 似乎找到了程序集,我可以在其中导航类型等.我也可以毫无问题地构建项目,但是当 IIS 运行服务器时,我收到一个内部服务器错误,说明:

VS seems to find the assemblies, where I can navigate types etc. I can also build the project without any issues, but when IIS then runs the server I get an internal server error stating:

FileNotFoundException:无法加载文件或程序集myDLL,版本=1.0.0.0,Culture=neutral,PublicKeyToken=null".系统找不到指定的文件.

FileNotFoundException: Could not load file or assembly 'myDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

引用的 DLL 位于调试文件夹中,真正奇怪的是,如果我在与 Web 堆栈相同的解决方案中创建一个新的 ASP Core 项目,我可以毫无问题地引用和使用它.

The referenced DLLs are in the debug-folder, and the really weird thing is that if I create a new ASP Core project in the same solution as the web-stack, I can reference and use it without any problems.

为什么只有在 web-stack 解决方案之外的项目上运行时才会发生这种情况,我该怎么做才能让它在任何地方都可以运行?

Why is this happening only when running on a project outside the web-stack's solution, and what can I do to make it runnable everywhere?

推荐答案

VS 2017 中的 .NET Core 工具(<15.3 预览版)/.NET CLI

2.0 不完全支持在磁盘上引用程序集.您需要将库打包为 NuGet 包或使用项目引用(相同解决方案").技术原因是所有必需的程序集和版本都在编译期间解析并写入 .deps.json 文件.加载任意程序集时,这可能会失败,因为无法找到程序集或其依赖项(或相互冲突).

The .NET Core Tooling in VS 2017 (< 15.3 preview) / .NET CLI < 2.0 doesn't fully support referencing assemblies on disk. You need to package the library up as a NuGet package or use a project reference ("same solution"). The technical reason is that all the required assemblies and versions are resolved during compilation and written to the .deps.json file. When loading arbitrary assemblies, this might fail because either the assembly or its dependencies cannot be found (or a conflict with each other).

这篇关于ASP .NET CORE 找不到带有自定义程序集的文件或程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆