Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio shows endless messages "Code generation for property 'valueMember' failed."

After several days of happily hacking away on this C# app using Visual Studio 2008, I get struck by a barrage of error dialogs showing:

Code generation for property 'valueMember' failed.
Error was: 'Object reference not set to an instance of an object.'

This happens now often when I make a tiny change in the designer, e.g. shift a control a few pixels, and then try to save. Several such error dialogs appear each second, keeping me busy cancelling all those by hammering the Enter key while trying to get alt-F4 to get VS to close.

Eventually I do get VS to close and to save the changes I made. After restarting VS, I do "clean" on the entire project, then "build" and everything works fine, the app runs fine, no problems.

Until I make another slight change in the form designer.

I don't know about any property valueMember in my app.

This makes me crazy, it is a real showstopper for my project. Any help is appreciated.

like image 952
Roland Avatar asked Nov 22 '12 17:11

Roland


6 Answers

Try to Close and reopen the Visual Studio. maybe it seem silly, but it works!!

like image 99
Chani Poz Avatar answered Nov 11 '22 12:11

Chani Poz


You can debug the designer using another visual studio and attach to process. If you got exception it should be easy to find it that way. In general when openning the designer the constructor and of course initializeComponent is running.

like image 16
shanif Avatar answered Nov 11 '22 11:11

shanif


As this is happening at design time, it is likely that you have a custom control which requires a parameter or other value which does not have a default.

When in design view in Visual Studio; a control instance is created to render it on the visual editor, but if the control requires a property to be set before it can be rendered, it will result in an error.

Can you check that all custom controls have default values, and anything referenced in the constructor that cannot have a default is wrapped by DesignMode property - see http://msdn.microsoft.com/en-us/library/system.componentmodel.component.designmode.aspx.

like image 12
Kami Avatar answered Nov 11 '22 10:11

Kami


Similiar to @Chanipoz's answer (close/re-open) my component-rich/user-controls-everywhere forms app started to compile happily after I closed down the main form designer window.

I've had this code stack for years and have never seen the error until today. Not sure where it's coming from. But, something today about having the form open in the designer made everything unhappy. Simply closing it off of the screen made it all go smooth.

like image 2
bkwdesign Avatar answered Nov 11 '22 11:11

bkwdesign


Use another instance of Visual Studio to attach to the first instance of visual studio.

Go to Debug-> Attach To Process and look for the devenv.exe process. Since you'll have two devenv.exe processes running you'll probably want to pick the one with the lower ID, that's usually the first instance of visual studio that was run.

like image 1
Garrett Banuk Avatar answered Nov 11 '22 11:11

Garrett Banuk


I had to face this problem. As I have found the solution below I am facing this issue in my customized control.

we need to implement like this

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public MyCustomclass _Prperty { get; set; }
like image 1
Ponsingh A Avatar answered Nov 11 '22 10:11

Ponsingh A