The experience of the resource file in VS, it is recommended to pay attention!

xiaoxiao2021-03-06  64

Suppose there are two files: main.exe and lib.dllmain.exe calls a class in lib.dll in lib.dll, using Assembly.Getexecutingassemblying will point to lib.dll if you use assembly.geteTryassembly There will be a question that points to main.exe and a problem worth paying, this problem has made me in an afternoon. After I call Assembly.getexecutingassembly in lib.dll, use stream filestr = asm.getmanifestResourceStream ("sunset.jpg"); getting the STREAM of the embedded resource file, but always wrong, always can't find the reason, and then discovered my This project file is written in the default namespace in the general namespace in the General of Common Properties in the configuration dialog in this project. This default name is completely different from my lib.dll's primary Namespace, so I will empty it (the default will call The same name as my lib.dll's primary namespace), the getManifestResourceStream here will work normally. God, such a problem, I have made me an afternoon, I am mad at me. Someone asked, how would the default NameSpace be new? Oh, this will go to ask the author to export the VS project file plugin in SharpDevelop. Because I debug is the project file exported.

转载请注明原文地址:https://www.9cbs.com/read-87222.html

New Post(0)