Visual Studio Designer - Value cannot be null. Parameter name: objectType - by Larry4321

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 579301 Comments
Status Closed Workarounds
Type Bug Repros 8
Opened 7/27/2010 10:40:26 AM
Access Restriction Public


When I try to load the form into the Visual Studio 2010 designer, I get the error message that "Value cannot be null, Parameter name: objectType. This is a form that loaded without problems in the VS 2005 and VS 2008 versions. It is a form that serves as a base form to other forms in solution and oddly, the forms that inherit from this form load into the designer correctly without error (at least for now).

If I click on the "Ignore and Continue" link, then the designer does load the form. However, there are some Handles clauses that get removed from the event handlers of one of the controls on the form. I noticed that there are other posts that report a similar problem that results in Handles clauses being removed from code.

I tried adding the Handles clauses back, but the next time I try to being the form into the designer it reverts to having the "Value cannot be null...." problem.

Sign in to post a comment.
Posted by arnie on 8/11/2015 at 11:08 AM
Just an update many years later...

I can repro exactly what Larry4321 is seeing. In my case I have simple resource dictionaries that are merged to provide enhanced styling/templates at runtime. I'd like to see them take effect at design time as well. I get all kinds of blue squiggly "Value cannot be null" exceptions. In my case it says Parameter Name: "Item".

When I look at a stack trace of the exception it is the actual resource dictionary name/path to be merged. The stack says its null. However, I know the code name/path is correct.

When I go through the Comment/UnComment girations using Ctrl K+C etc. then it begins to work.

I noticed that in the recently released VS2015 there is a new designer option that says "Run project code (if available)" if that is turned on then ALL of my issues related to this defect go away and everything works perfectly everytime. When I turn it off in VS2015 I see all these problems come back. When I turn it on everything works perfectly again.

Wanted to let everyone know that A) This is all fixed in VS2015 if you have this option turned on B) Let Microsoft know that if whatever that feature/option is doing under the hood if it can be back ported to VS2013 that would be a huge help for my company (3000+ software engineers).

Posted by Mark F VB Coder on 4/23/2014 at 11:16 AM
I just found this dialog...had the same error, which prevents openning form in designer mode without scary error message...soffice to say, designer mode is very picky and causes many panic attacks...MSFT...please make this better!! Scary IDE is bad idea for keeping developers around...even if many features good, typing is now getting really too strict, and IDE essentially is a 'blind alley'...have lost many hours for no good reason...

What I can say is the Handles syntax is particularly annoying...handles get los (disappear magically), and it seems, must be typed seems I fixed this instance of panic after changing lower case to upper case for my handle object name to exactly match the button, maybe the handles object name is not updated correctly for the underlying form object name....and is literally case sensitive on all if your button name is in upper/lower case, make sure the handle name matches exactly...because the IDE will not update the name correctly...or did not for me this time around...

In general, we need a better and more obvious variable / object name symbol table, and/or less strict typing...strict typing can become a waste of time, and time is I prefer the looser old way of doing things, regardless of risk to double using a variable unintentionally...please loosen up the IDE, or make it easy to solve name references / cross-references...also, 'protecting' variable spaces (namespaces) is really a pain in the rear, with little added value...I am not a nun, and I do not need to be beaten with a systematic stick...let us do the coding so MSFT can have some new products...otherwise, the good ideas at MSFT...may not get leveraged...and JAVA and other platforms will continue to grow while MSFT withers...take off the chains!!
Posted by Jose M. Peguero on 3/20/2014 at 7:44 AM
i resolved this, i had two procedure with the sema event Handles.
Posted by vasmatics on 10/11/2011 at 1:32 PM
Step 1: I imported a solution from VS 2003 to 2010, and everything went fine in the beginning.

Step 2: After I deleted the existing datasets and created new ones, normally I had to delete the references to these datasets from the designer vb files as well. This I did.

Step 3: When I clicked on the designer window, it came up with the error mentioned above.

Solution: There was a handle set to a databinding object in the vb file (not the designer vb, but the "normal" vb). After I deleted that handle and saved the file, then the designer was working again.
Posted by KeythH on 8/17/2011 at 12:28 PM
I echo sophie396
Posted by sophie396 on 11/18/2010 at 4:01 PM
This bug should not be closed.

I have exactly the same problem. In my case only one method is calling the "Handles" clause. I have tried using "AddHandler" instead (same fault) and also added a "If Not DesignMode..." clause, but the fault still exists.

I was able to work round the fault ( a SizeChanged event) by hosting the control in a container, setting the control's Dock value to DockStyle.Fill, and handling the SizeChanged event of the new host container object.

As far as I am aware, this bug appeared out of the blue. That specific code had been stable for weeks, then one day it appeared without my having changed the code at all. From my research, I am not the only person who had the fault appear making any explicit code changes in the area where the problem seems to manifest itself.

There are LOTS of references to this on various forums on the Net...It is a real bug and a real problem
Posted by Microsoft on 7/30/2010 at 12:31 AM
Thanks for the detailed information. Based on your comment, I will close this feedback. Should you find any bugs in the future, please feel free to let us know.
Posted by Larry4321 on 7/29/2010 at 7:28 AM
I've narrowed down the problem to a few lines of code. It turns out that there were two methods declared that had Handles clauses for the same event. If I comment out the methods and rebuild and then uncomment the methods and rebuild, then I can bring up the form in the designer. So, I've consolidated the two methods into one event handler and hopefully that's the last I'll see of this error.
Posted by Larry4321 on 7/29/2010 at 5:21 AM
This is going to sound bizarre, but I'll let you know anyway. I stumbled across away to get around this issue. As I was trying various things, I commented out all of the code in the forms class except the class declaration by selecting the code lines and then using the Ctrl-K Ctrl-C editor shortcut. I then rebuilt the solution and of course I got a slew of build errors. So, I then went back into the editor and selected all the code lines that I previously commented out and then used the Ctrl-K Ctrl-U editor shortcut to uncomment the lines. I then rebuilt the solution. Lo and behold, when I tried bringing the form up in the designer it loaded ok. I used the VS compare to check for differences between the file before and after the commenting/uncommenting and found just a few differences. Unfortunately, the differences must just be in the whitespace of the lines because there is no differences in the actual code. I plan to try to look into whether there are any binary (non-visible) characters in the lines, but the code was entered using the VS editor so I don't expect to see anything except maybe some variation in the amount of spaces used for indenting.
Posted by Microsoft on 7/29/2010 at 2:02 AM
I am currently standing by for an update from you and would like to know how things are going on your end. If you could get back to me at your earliest convenience with information I request, we will be able to make headway towards a resolution. I look forward to hearing from you.
Posted by Microsoft on 7/27/2010 at 8:46 PM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 7/27/2010 at 5:04 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(