简体   繁体   English

嵌入的资源 txt 文件未更新

[英]Embedded resource txt file is not updating

I have a project with a .txt file in a folder.我有一个文件夹中有一个 .txt 文件的项目。 The .txt file is set to Embedded Resource. .txt 文件设置为嵌入式资源。

I use this code to read it:我用这段代码来阅读它:

var assembly = Assembly.GetExecutingAssembly();
var manifestResources = assembly.GetManifestResourceNames();

string s = manifestResources.Single(c => c.EndsWith("Cats.txt"));

Which works great.这很好用。

However I updated Cats.txt and noticed my project didn't update.但是我更新了 Cats.txt 并注意到我的项目没有更新。

I deleted Cats.txt and found that it is still working fine and reading the file.我删除了 Cats.txt,发现它仍然可以正常工作并读取文件。

I tried cleaning my solution, rebuilding, and iisreset, but it seems to insist the file is still there in the assembly despite me removing it.我尝试清理我的解决方案、重建和 iisreset,但尽管我删除了它,但它似乎坚持该文件仍在程序集中。

Any ideas?有任何想法吗?

Actually, the problem is solved by Cleaning the solution first, and then Building it again.实际上,问题是通过先清理解决方案,然后再构建解决方案来解决的。 I did not have to quit Visual Studio to update my embedded resource.我不必退出 Visual Studio 来更新我的嵌入式资源。

重建解决方案(或启动项目)更新嵌入式资源。

Okay so I fixed this by restarting visual studio.好的,所以我通过重新启动 Visual Studio 解决了这个问题。 I have no idea how that affected it.我不知道这如何影响它。

When I inspected the properties of 'assembly', the CodeBase attribute was pointing to an older copy of the DLL in a completely different folder, that was somewhere else on my hard disk, that I had open in another Visual Studio window.当我检查“程序集”的属性时,CodeBase 属性指向一个完全不同的文件夹中的 DLL 的旧副本,该文件夹位于我硬盘上的其他位置,我在另一个 Visual Studio 窗口中打开了该文件夹。

I have no idea what underlying mechanism caused this to happen, I definitely had the correct version of the solution open and I was debugging it.我不知道是什么底层机制导致了这种情况的发生,我肯定打开了正确版本的解决方案并且我正在调试它。

Closing the solution and opening it again fixed it.关闭解决方案并再次打开它修复了它。 Chalk this one up to bizarro caching behaviour or something.将此归结为奇异的缓存行为或其他事情。

I had the same problem, cleaning building and many other things didn't work.我遇到了同样的问题,清洁建筑物和许多其他事情都不起作用。 I had to modify the resource designer.我不得不修改资源设计器。 After that, the resources were rebuil correctly之后,资源被正确重建

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

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