简体   繁体   English

类库项目文件未编译为 .dll 或调试

[英]Class Library Project File not compiling into .dll or debugging

in my solution:在我的解决方案中:

  • i have a class library project that compiles into a dll.我有一个编译成 dll 的类库项目。
  • i have a web project.我有一个网络项目。

(i have multiple solutions with different web projects but the same class library) (我有多个具有不同 Web 项目但具有相同类库的解决方案)

one of the files in the class project (utilities.cs) - all of a sudden won't compile into the .dll类项目中的一个文件 (utilities.cs) - 突然无法编译到 .dll 中

i had made a change to this file, but the change wouldn't show on the website.我对该文件进行了更改,但更改不会显示在网站上。 so i put a breakpoint in the .cs file, and tried running it... breakpoint didn't get hit!所以我在 .cs 文件中放置了一个断点,并尝试运行它......断点没有被击中! eventually i put a breakpoint in the .aspx file that called the function.最终我在调用该函数的 .aspx 文件中放置了一个断点。 then i stepped the debugger one line on, so it would step into the .cs file, except i got the error:然后我将调试器放在一行上,所以它会进入 .cs 文件,除非我收到错误:

"This source file has changed. It no longer matches the version of the file used to build the application being debugged." “此源文件已更改。它不再与用于构建正在调试的应用程序的文件版本相匹配。”

so the code in utilities.cs is not being updated into the dll.所以utilities.cs 中的代码没有被更新到dll 中。 which is weird, because code in my other .cs files IS being updated (i tried changing a few lines) and IS able to catch the debug.这很奇怪,因为我的其他 .cs 文件中的代码正在更新(我尝试更改几行)并且能够捕获调试。

any ideas how to fix this?任何想法如何解决这一问题? or even what the cause of the problem is??甚至问题的原因是什么?

Try:尝试:
Right click on Solution in Solution Explorer -> Properties -> Configuration Properties -> Make sure Build checkbox is checked for your class library.右键单击解决方案资源管理器中的解决方案->属性->配置属性-> 确保为您的类库选中构建复选框。

When You adding new references to Web project You must choose "Projects" tab:当您向 Web 项目添加新引用时,您必须选择“项目”选项卡:

Projects lists all reusable components created from local projects.项目列出了从本地项目创建的所有可重用组件。

  1. Add or Remove References in Visual Studio 在 Visual Studio 中添加或删除引用
  2. Add a Reference to a Visual Studio Project in a Web Site在网站中添加对 Visual Studio 项目的引用

Always rebuild all projects in Release and Debug mode.始终在发布调试模式下重建所有项目。

You need to find out why the DLL will not build:您需要找出 DLL 无法构建的原因:

  • Look at the output window for any errors查看输出窗口是否有任何错误
  • Check the Errors window检查错误窗口

Fix the errors and try building again.修复错误并再次尝试构建。

The dll that you are trying to debug is from an older version of your code that did compile OK and the debugger pickes that up and is trying to debug against that - it is complaining because the code and the dll no longer match.您尝试调试的 dll 来自您的代码的旧版本,该版本确实编译正常,并且调试器选择并尝试对其进行调试 - 它正在抱怨,因为代码和 dll 不再匹配。

Try doing a Build -> Clean on the solution and then rebuilding to see the errors.尝试在解决方案上执行 Build -> Clean,然后重建以查看错误。

I did exactly what @nightcoder said but a simple change was required.我完全按照@nightcoder 所说的做了,但需要进行简单的更改。 Go to Configuration Properties(Right click on Solution in Solution Explorer -> Properties -> Configuration Properties) and select "All Configurations" in Configuration option.转到配置属性(在解决方案资源管理器中右键单击解决方案 -> 属性 -> 配置属性)并在配置选项中选择“所有配置”。
This created the .dll for me这为我创建了 .dll 在此处输入图片说明

This happened to me after switching between branches in a project which have significant differences between them, I tried every solution from the web but non worked.这发生在我在一个项目中的分支之间切换后发生的,这些分支之间存在显着差异,我尝试了网络上的所有解决方案,但没有奏效。

Finally, I had to delete my local project files and clone the project from the GitHub repo again, after that when I started the project, the project build worked without errors, and dll was generated.最后,我不得不删除我的本地项目文件并再次从 GitHub repo 克隆项目,之后当我启动项目时,项目构建没有错误,并且生成了 dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM