Solved

VS 2013 invalid argument value parameter name

Posted on 2014-09-10
18
330 Views
Last Modified: 2014-09-26
I have a single form in a WinForms application that gives me strange errors.

If I open the forms designer in VS2013, I can make one change the the UI, and save it.  But when ever I make a second change I receive an error informing me " An error was encountered during code generation"  With a message Invalid argument value, Parameter name: name

And I have to close the form without saving to move forward.  If I did not save the first change, that would also be lost.

Once I have closed the form without saving, and losing my changes, I can reopen the form, and again make one change and save it, then I get the same error.

The odd thing is, if I make no changes the program Builds and Runs correctly.

I have been working on this app on and off for years, and never had a problem until the last couple of days.

Judging by the parameter name is a lower case name rather than a Name, I am guessing the problem is in a resource file or xml file.  But I have compared them all with other forms and they appear the same.

I cannot recreate the form from scratch, it is a very complex form that would take literally 100's of man hours to recreate it.

Has anyone experienced this before?  And if so, what was the fix?

Failing that, can anyone suggest a way to pin down exactly where in the form the error exists.

Every other form in the app can be edited correctly without problems.
0
Comment
Question by:townsma
  • 9
  • 4
  • 2
  • +2
18 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40314175
you will have to go through the generated code and hunt for your error
0
 
LVL 6

Author Comment

by:townsma
ID: 40314279
Many thanks for the suggestion, but I have already spent two days looking at the code. And used several code analyzers like resharper. But nothing jumps out as being wrong.  That is why I was hoping someone else may have experienced the same problem.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 40314297
are you using a code repository (TFS or any other) that you could use to compare the latest version with the one just before?
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40314516
Hi townsma;

I have not come across this issue but I am wondering have you tried to do a Clean and then recompile to see if that corrected the issue?

To do a Clean do the following from the Visual Studio main menu.
Build -> Clean Solution
Then recompile the project.
0
 
LVL 6

Author Comment

by:townsma
ID: 40314562
Hi, thanks for the suggestion. I have tried that a couple of times. But no luck.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40314609
I have one more suggestion. If you have a text editor which will also allow you to view the text file in Hex format use it to view the form and code behind files and make sure that there are no characters that are not visible in text mode that do not belong. Such characters have the Hex value above 7F.
0
 
LVL 6

Author Comment

by:townsma
ID: 40316204
Now I am really confused.  Using TFS, I have taken the problematic form all the way back to when the branch was first created, about 3 months ago.  

I know it was working then as we have made quite a few changes to the UI since then.  But now even the 3 month old version will not let me make changes and save them.

I have tried this on two different systems, both the same.  As I though the problem may be related to the projects resource file, I even took that back to the branch version, exactly the same.  

So now I have a problem that appears to be only affecting one form, but the problem is not in the form itself.  The problem is, this solution has around 100 projects, some with 20 - 30 forms and user controls.  And literally millions of lines of code.  So where do I start looking now?

I have searched the web extensively looking for anyone else who has experienced this problem, but again, no luck.

Any and all help will be gratefully received at this stage.
0
 
LVL 6

Author Comment

by:townsma
ID: 40316247
Ok, the confusion grows.  I have now opened a completely different branch, one that has not been opened in more than a year. The same form has the same problem in that branch.

This is looking more like a VS problem and less like a code problem.

In addition, this form was originally created in VS 2003, and updated several times to the latest VS2013, with the framework being updated also from 2 to 3.5 to 4.  The original form did not has a frmName.Designer.cs file, all the init was in the fmrName.cs file  That was how the original VS created them. But since today, VS is creating the designer file, but not linking it properly to the main file. i.e. the main form class is public the designer is internal, neither is set to partial, and the designer file contains a second empty constructor.

It has never done this before.  

I think it is time to build a fresh system, with a basic VS, no add-ons, just the libraries required to build the app. And see if that is the same.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 40316542
do you have a third party component on this form? Have you tried to repair your Visual Studio?

can you create a dummy new project (outside your big solution) and add your form to that project to see if it can be opened from there?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Author Comment

by:townsma
ID: 40316591
There are many third party libraries on the form, i.e. Infragistics, DevExpress etc.  But none of these have changed or been upgraded in the last few months.

I have tried a repair on VS, but as it is affecting both of my systems in an identical way, I find it hard to believe a corrupt VS installation would be the cause.

I have tried 6 different versions of the app, including completely different branches of the of the code, some that have not been opened since they we stored after full testing more than a year ago. So I am 100% convinced it is not a code problem.

Thanks
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40328496
you may create a new form and add components of the corrupt form until you either have an identical (looking) but working form or you have found the wrong control which could not be handled (any more) by vs2013.

Sara
0
 
LVL 6

Accepted Solution

by:
townsma earned 0 total points
ID: 40329427
I must say, this problem has me baffled.  It affected all out VS 2013 systems, and all in an identical manner.  Which unless they all have exactly the same corruption or bug, means the problem must be in code.  

But equally, it also affected all versions and all branches of the code, which would indicate a problem with the IDE?

It only seemed to affect one form, again indicating a code issue, but how could a code issue jump between all branches and all versions of the code on so many systems?

I tried removing the form from the project completely, deleting the source files, and then added it again from an old version, never opened in more than a year, and it had exactly the same problem. Again pointing at environment not code.

Next I tried creating a new form, and copying all the controls one at a time to the new form, no problems.  I then copied all the code, exactly as it was, to ensure all the controls were wired up correctly. Again the issue did not manifest itself. I then used Araxsis Merge to compare the source files of the old and new form,  No discernible differences found, which is what I expected as I copied the code verbatim. But yet the new form worked, and allowed me to edit it correctly.

I then removed the old version of the form from the solution. Everything run fine.  But to test a theory, I pulled the latest version to the other systems, they all worked.  I then reopened an old branch, and it also worked.

I cannot explain how one version of a file in one TFS branch could affect so many systems, and so many other TFS versions / branches of an app.  But that is exactly what happened.

I also cannot explain what is different between the broken version, and the new version, as both versions of the form were identical, as proved by Araxis Merge.

I guess this will just go down as one of the great unsolved mysteries.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40329755
I then used Araxsis Merge to compare the source files of the old and new form,  No discernible differences found
you should see that the original resource of the corrupted form also could be read and - once - could be modified. so the issue was not so much that the old source somehow was corrupt but that the form resource editor was not able to store a valid form file if you modify the original form in the IDE. so, the resources to compare is not the working and old resource but the old resource and the modified resource or the modified resource (not working) with the new one created from scratch. I would use a text compare tool rather than a resource compare and it should be possible to identify the 'invalid argument value parameter name' that was written wrongly to the form file.

Sara
0
 
LVL 6

Author Comment

by:townsma
ID: 40329814
Hi Sara,

Araxis Merge does compare text, or in whatever format the file is in.  

Whilst I accept that the files would probably be different after the error has occurred, there is actually no way to check.  The save fails because VS is unable to create the modified file. The only way to get past the error message is to undo the changes in the designer, and it is this version I tested against, amongst others.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40329943
The save fails because VS is unable to create the modified file.
didn't you say you were able to make one change and save it?

I looked for the error message of your original post. there were only a few hits but the error occurs if a parameter name exists in xml code which was unknown. I found a sample where the error message was due to the fact that the name 'User Story' in a tfs script no longer was supported and needed to be replaced by 'Product Backlog Item'. can you check whether your output window has some more information? or whether there is a log entry in the event viewer regarding the error?

Sara
0
 
LVL 6

Author Comment

by:townsma
ID: 40330033
Thanks for the reply.

Yes, I checked the saved once version, and again it finds no key differences.

I gathered it was in the xml code as the parameter is called name and not Name. But could not find any xml files showing any corruptions.

With regards to TFS User Stories, we do not use User Stories or scripts, so I cannot see how that would cause an issue.
0
 
LVL 32

Expert Comment

by:sarabande
ID: 40330207
I guess this will just go down as one of the great unsolved mysteries.
looks like you were right :)

you could send a bug report to ms. some years ago I reported a bug in a library and it was solved in the next version.

Sara
0
 
LVL 6

Author Closing Comment

by:townsma
ID: 40345661
No actual cause for this problem was ever identified.  The only solution appears to have been delete the old form and create a replacement.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now