Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

c# - ASP .NET CORE could not find file or assembly with custom assembly

I've ran into a weird problem.

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 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: Could not load file or assembly 'myDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...