简体   繁体   中英

Embedded resource txt file is not updating

I have a project with a .txt file in a folder. The .txt file is set to Embedded Resource.

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.

I deleted Cats.txt and found that it is still working fine and reading the file.

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.

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.

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

Okay so I fixed this by restarting 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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