How do I cure a "Missing Manifest Resource Exception?"
-
mercredi 12 octobre 2005 05:20I'm writing a program in VB 2005 Express Beta 2. In one section I allow the user to repeatedly access a resource file that was created using a ResourceManager object. Each time the user is done with the section I use a ReleaseAllResources statement to close the connection to the resource file.
Repeatedly calling this subroutine does not appear to cause a problem. However, I just wrote another subroutine which allows the user to write certain choices and results from the application to a file on disk. I create both a filestream object and a streamwriter object to write to the file. Each time the routine finishes, I invoke the close method for the streamwriter object followed by the close method for the filestream object to make sure that I have written everything in the buffer and closed the connection to the disk file.
In some way that I do not understand these two routines (the ResourceManager routine and the file writing routine) conflict with each other, generating the exception described in the subject line of this message. Specifically it occurs in the following circumstance: the user calls the ResourceManager routine, and it processes without error. Then the user runs the file writing routine, and it too processes without error. Then, if the user goes back to use the ResourceManager routine again, the error occurs just as soon as the routine reachs the GetObject statement in the ResourceManager routine.
Repeated calls to the ResourceManager routine without calling the file writing routine cause no problem, but injecting the file writing routine into the middle of these calls causes an error. What's going on? Am I not closing out the ResourceManager routine properly? Am I not closing the filestream/streamwriter routine properly? I'm at a loss. Thanks.
Toutes les réponses
-
mercredi 12 octobre 2005 17:58Without seeing your code I'm just guessing here but the exception being generated indicates that there is a problem with your .resources file. Take a look at KB Article 839861 maybe that will point you in the right direction.
HTH,
-B -
jeudi 13 octobre 2005 18:47
Beth,
Thanks, I'll take a look at that article. I'll try to replicate the problem with a trimmed down piece of code (since both routines are interwoven into a lot of other UI code in my application that is neither relevant nor likely the cause of the problem) and post the code.
In the meantime, I decided to abandon my attempts to create a .resources file at runtime and just embed the bitmaps as resources directly into my application. I then access them as needed with the .Assembly.GetManifestResourcesStream() method applied to an instance of a System.IO.Stream object. Apparently that works perfectly, so my motivation to find a solution to the exception is diminished. I kinda would like to track it down just for my own edification though.
Thanks for your response. -
vendredi 14 octobre 2005 22:51Modérateur
Hi,
You can also use the Resource Editor of your project to add a Bitmap and access it easily without going through .Assembly.GetManifestResourceStream if you're using Visual Studio 2005.
- Double click on 'My Project' node in your project.
- Select Resources tab.
- Add Resource | Add Existing File. Browse to your Bitmap.
Now you can access your Bitmap in code using
My.Resources.MyBitmapName
It returns a System.Drawing.Bitmap.
Hope this helps, -
mardi 30 septembre 2008 23:56
I realize this post is quite stale, but having just run into this I thought I'd chime in. I arrived at this exception in an entirely different way however, while trying out dotfuscator. In my case the problem was caused by virtue of me having inadvertently obfuscated my project's properties. For example, if you have a winforms app and take the default of obfuscating your entire .exe assembly including the Resources class defined in your properties\resources.designer.cs file, you can expect missing manifest resource exceptions to be thrown. The solution in my case was to exclude the application.properties item under the Rename tab in the dotfuscator config section.
Hope this helps somebody...
Cheers,
Jack- Proposé comme réponse Guillermo López Alejos jeudi 22 janvier 2009 16:05
-
lundi 12 janvier 2009 11:10Hi Jack,
This certainly helped, I got the same error while testing the dotfuscator ;-)
Thanks for posting the information!
greetings,
Douwe -
lundi 18 janvier 2010 22:54
This post is even more stale now, but I was just minding my own business and got this exception by a different route, and thought I'd post this in case it helps anyone.
By default, the Resources.resx for a new .net project is created in the Properties folder. So if you try to get, say, a string from there, and you do it like this:
rm = new System.Resources.ResourceManager("myNamespace.Resources", myAssembly);
string s = rm.GetString("myString");the GetString throws an exception.
You've got to either move the Resources.resx to the root of the project, or get the ResourceManager thus:rm = new System.Resources.ResourceManager("myNamespace.Properties.Resources", myAssembly);
-
mardi 27 avril 2010 07:06
HEAH jeff,,
Can i know what is properties in "mynamespace.properties.resource" in ur last comment
-
lundi 19 juillet 2010 20:16
Keshav,
It is a segment of a namespace.
-
lundi 6 septembre 2010 01:51
This post is even more stale now, but I was just minding my own business and got this exception by a different route, and thought I'd post this in case it helps anyone.
By default, the Resources.resx for a new .net project is created in the Properties folder. So if you try to get, say, a string from there, and you do it like this:
rm = new System.Resources.ResourceManager("myNamespace.Resources", myAssembly);
string s = rm.GetString("myString");the GetString throws an exception.
You've got to either move the Resources.resx to the root of the project, or get the ResourceManager thus:rm = new System.Resources.ResourceManager("myNamespace.Properties. Resources", myAssembly);
Hi, first at all, i'm sorry about my english.
I'm using resource files, and I need to get the part of "myNamespace.Properties" dinamically, I mean, getting the "namespace" and the "property" that are being executed at the right time.
I really don't know if that can be done or it is just impossible.
For instance, I have a 3 layer system (where each layer is a different project inside the same solution), one of them is the "View Layer", and other one is the "Business Layer".
For the "View Layer" I have the WindowsApplication1.Form1.resources and the WindowsApplication1.Form1.en.resources
For the "Business Layer" I have the BussinesLayer.exceptions.resources and the BussinesLayer.exceptions.en.resourcesI also have a "Resources Class", that I can call from wherever I want in the solution, but I need to get that "route" and I can't get it.
If any of you could give me a hand with this, I would be very grateful.
Thank you.
- Proposé comme réponse joehinder mardi 30 novembre 2010 22:22
-
mardi 30 novembre 2010 22:25
One other thing to note (5 years too late of course) is that changing the namespace for the project can cause the problem to occur. For example:
If you have a project named 'bar', but you change the namespace to 'foo.bar' and then add a resources file, Visual Studio will go nuts and you won't be able to just do
foo.bar.myResourcesFile.theResource
messy.
-
samedi 23 juillet 2011 19:31
Add "ScriptManager" from "AJAX Extensions" made an ID just to answer you and a guy with similar query! :)
-
jeudi 18 août 2011 15:29
Jeff,
I stumbled onto the problem, same as countless others (which might be indicative that Microsoft might wish to clarify its documentation). Inserting "Properties" into the basename solved my issue, too.
Thanks for the tip !
-- Jeff
-
vendredi 3 août 2012 02:02That was my issue. Thanks Pargat!

