Object reference not set to an instance of an object. -Resources.resx
After converting my project into VS2010, everything l开发者_如何学Cooks fine ( gui, etc..), but i can't build it because of this error. When i double click on the error it leads me to the resource file but doesn't show me where the problem is.
Object reference not set to an instance of an object. -Resources.resx
My project works fine on VS2008, was built on .net 2.0 , does any one know how to fix this ?
Thanks
In my case this happened after copying a form from one project to another. It seems VS lost the reference to one of the local resource images. Re-adding the image fixed the issue.
Well, something got messed up, but without bashing your head around it too much:
Use row headers to select all rows in the resources file.
Copy the selected content to Notepad.
Delete the resources file in Visual Studio.
Create a new resources file with the exact name.
Copy/paste the content from Notepad back to the resources file.
That should do the trick. This only works with string resources. If you have other types of resources, I am afraid that simple copy/paste will not be as simple. Either way, I think that recreating the resources file is the easiest solution.
Principle: "Don't know, don't care. Just make it work" :)
I had the same issue when copying a windows form from one project to another. After some research I found that it was due to the version of the .Net Framework.
Make sure that the project where the resx file sits is the correct version. If you copied it from Project A to Project B, make sure that the .Net version of Project B is the SAME as Project A.
See http://www.codeease.com/object-reference-not-set-to-an-instance-of-an-object-in-resx-resource-file.html
Hope it helps you
I was moving project from XP 32 bit machine to 64 bit Win 7 machine. The project was Framework 2.0
In my case easy fix. In the resx file change all the Version=4.0.0.0 to Version=2.0.0.0
I got this problem when I worked from a network resource, even though I had write/read access too it. When I moved the files to a local folder, it started to work.
Something that often worked for me was modifying the resource files like this: 1. Go to the resource in design view and copy all the string entries. 2. Delete all the entries from the design view and save. 3. Go to the code view and remove the data entries/nodes (they were not removed on my machine, even though I removed them from the design view). 4. Rebuild the project. 5. Go to the design view and paste the entries you previously copied and save. 6. Rebuild and it should work.
Unfortunately my answer won't really help you, but is consistent with the ones above. The errors (seemingly) spontaneously went away.
Here's some other info that might help... (I had two of these errors) My scenario was I initially developed on VSexpress2010, 32bit XP. Recently upgraded to Win7 64bit. (clean install, bring all my code back in now...)
It seems this error is usually thrown by trying to reference some null object (I've lost the reference). So I tried this even though my code was working previously... No luck, but after I removed the new 'fix' code, the error for that object was gone. Just played around with the file.
I came across this page too http://www.codeease.com/object-reference-not-set-to-an-instance-of-an-object-in-resx-resource-file.html . I searched my remaining resx, but had "Version=2.0.0.0". Anyway, after the search, I debugged and it's gone.
Short answer: It's like magnets, how the F##k do they work? Just play around with your file, and keep debugging... hopefully eventually it'll work.
- recreate the resource file copy/pasting (assuming it's text)
- make some edits in your file. save. remove the edits. save again.
- search around the file.
chances are it's not your code, and some mystery VSbug.
Good luck.
+1 @Boris's answer because it really is a case of
"Don't know, don't care. Just make it work" :)
In my case I convert my project from framwork 4.0 to 2.0 and also copy a Form .cs file and Designer file after that I am getting same error. But as I delete the .resx The error gone. Please try to delete .resx may it help you!
Problem occurred after an unspecified crash of VS-2010 which apparently corrupted the project.
The RESX file was not changed at all (as determined from a backup copy of the project). There seemed to be invalid references in the VSPROJ file. I was not sure how to correct them by direct edits.
As per "Rohan" in 2012. I removed a background image from a form and the problem went away.
In my case, the problem arose when I copied the project to a new location. The problem was solved when I copied all the resx files from the original project, after verifying that the project compiled fine, and pasting them into the folder of the project that had issues. Clearly, a corruption issue that seems to be common when copying projects to new locations.
精彩评论