DEV Community

Rachel Soderberg
Rachel Soderberg

Posted on

Resolving VS Error CS0030 Cannot Convert Type 'Data[]' to 'Data'

Most of the time Visual Studio is pretty good about telling us where syntax errors and other bugs are hiding. Occasionally though (even after our tech lead has warned us to be on the lookout for "that one bug" they mentioned) even the best of us get stumped. Some of the most challenging bugs can be run time errors - especially the ones that are hiding deep within the code base, don't cause any Intellisense warnings or errors, and aren't developer-caused. In the case of the CS0030 error, it happens in a generated file in which you're warned "Changes to this file may cause incorrect behavior".

When I ran across this issue, it dawned on me after perhaps a little too long that my tech lead's infamous "double bracket bug" was exactly what was I was ramming my head against when I added our Salesforce web reference to my project. It also dawned on me that others may have the same hangup as me and that I should write about it to share. I'm not going to get overly technical in this article; my main goal is to get problem and resolution across in a written format.

Now to the problem! For whatever reason, when some web references are added, Visual Studio decides to be extra doubly helpful when generating the reference class files and builds something like this:

https://thepracticaldev.s3.amazonaws.com/i/6v7l84azs423j9ec3ood.PNG

(Note the double pairs of brackets, one of which I highlighted. That highlighted one shouldn't be there.)

Once you've run across this a time or two, it's like second nature to fix it, but for those who are in their first CS0030 rodeo I wanted to share how I found and resolved the issue:

In summary, if you have recently added one or several web references to your C# project and Visual Studio gives you an error code of CS0030 take a look at their reference classes and search for double brackets '[][]'. You may just have an extra pair or two hiding in there.

Top comments (0)