简体   繁体   中英

Unable to retrieve embedded resource stream

Using Visual Studio 2012, I am debugging a program to find out why loading a resource file using System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream isn't working. The file is being copied to the project's bin folder correctly - but invoking System.Reflection.Assembly.GetExecutingAssembly().Location is reporting that the program is not running from there - it is running from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\root\\c37f9465\\2be54367\\assembly\\dl3\\c92e18ea\\e852a1ef_ce6ad001 .

The program is a web service, and the error occurs in a DLL called ConnectSystem.DLL (another project in the same solution), and it is this file that resides in the Microsoft.NET folder.

If this is because of Dynamic ASP.NET Compilation , which looks like the best explanation, can anyone think of a way I can incorporate my configuration file please?

The resources you are trying to load shouldn't be next to the assembly, it should be compiled into it. GetManifestResourceStream only reads resources from the assemblies themselves.

You can try to set the build action of the resource to Embedded Resource , and the file should end up in your assembly. The name may vary, usually it has the namespace as prefix. You could use Reflector to see what the actual name is.

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