Quick Tip: Solving Visual Studio's "data is invalid"

In today's post, I walkthrough a stubborn issue of an older project not loading in Visual Studio 2019 and how to solve "The data Is invalid" message.

Written by Jonathan "JD" Danylko • Last Updated: • Develop •
Person holding a picture of a frowny face

What a weekend I had!

Not as in "Woo Hoo! What a fabulous weekend!"

No, this was more like "Oh crap! I installed drivers and now my primary machine isn't working and gives me blue screens every time I boot up."

Bear with me while I go through this. It eventually leads to my quick tip. :-)

Here's how it went: On Friday, I updated firmware on my laptop and then proceeded to install drivers. Once the drivers were installed, I thought I was ready to go.

I rebooted and logged in. After five minutes of everything loading, it blue screens. Every. time.

So what goes through your head when presented with this scenario?

  1. Try to back out every change you made (including the firmware) so you can get back to a stable state.
  2. Backup your data, reformat your hard drive, and start fresh.

While Window Restore Points include previous drivers, I was having a problem trying to restore firmware.

So I went with option 2. I felt it was about time to refresh the ole laptop anyway. ;-)

On With The Quick Tip

After loading the essentials back to my laptop, I had to load Visual Studio 2019. I installed it and loaded a project I'm currently working on.

Everything loaded except the primary "startup" web project.

I immediately get the following dialog:

Data is Invalid dialog box

Keep in mind, this is a fresh machine and I'm starting from scratch.

I right-clicked the project file to edit the .csproj.

While there were some paths missing, I felt this wasn't quite the issue.

I decide to perform a complete rebuild of the solution. All projects compiled except the primary project.

After I performed a complete rebuild of the project, I thought my build output would show me something.

Visual Studio Show Ouput Screen

Nope. I had four projects and three compiled successfully.

I clicked the dropdown and noticed another option in my output window.

Visual Studio build status

Oooooo....a solution option. Once I clicked on Solution, I found this interesting message.

Visual Studio Show Ouput from Solution Screen

"The IIS Express applicationHost.config file contains invalid entries and must be corrected before you can open project <ProjectName>."

Do I need IIS?

Once I saw this message, I realized I did forget to install IIS. While it wouldn't hurt (and I would eventually need it), I decided to install it.

  1. Click Start Menu (or WindowsKey)
  2. Type "Windows Features"
  3. Select "Turn Window Features on or off"
  4. Find "Internet Information Services" and click the checkbox to the left.
  5. Click OK to install.

After installation, I rebooted and tried it again.

Nope.

Bad ApplicationHost?

Finally, it boiled down to me taking "drastic" measures. I decided to delete the ApplicationHost.config. Of course, I first backed it up.

I needed to hunt down the applicationhost.config and the redirection.config files.

For IIS, the applicationHost.config is located at:

%windir%\System32\inetsrv\config\applicationHost.config

while the IISExpress version is located at:

%USERPROFILE%\Documents\IISExpress\config\applicationhost.config

I decided to go to "This PC > Documents > IISExpress > config"

I saw two files: applicationhost.config and a redirection.config.

Here's what I did:

I renamed the applicationhost.config to applicationhost2.config and ran Visual Studio 2019.

Since Visual Studio 2019 couldn't find the applicationHost.config, it created a new one.

That frickin' worked!

It's amazing how the simplest things can produce the biggest results.

Conclusion

If that didn't work, I was going to look at permissions, and if that didn't work, I would then ask my good friend, Google...

...who would then ask his best friend, Stack Overflow. ;-)

Everything seems to be working so far (except for that last driver I didn't load).

Hope this helps out some devs who have this same issue on fresh machines.

Did you have issues with a redirection.config file as well? How did you solve it? "Run as administrator?" Post your comments and let's discuss!

ASP.NET 8 Best Practices on Amazon

ASP.NET 8 Best Practices by Jonathan Danylko


Reviewed as a "comprehensive guide" and a "roadmap to excellence" with over 120 Best Practices for ASP.NET Core 8, Jonathan's first book by Packt Publishing explores proven techniques for every phase of the SDLC.

Learn industry-standard concepts to improve your coding, debugging, and deployment of ASP.NET Core websites.

Order now on Amazon.com button

Picture of Jonathan "JD" Danylko

Jonathan "JD" Danylko is an author, web architect, and entrepreneur who's been programming for over 30 years. He's developed websites for small, medium, and Fortune 500 companies since 1996.

He currently works at Insight Enterprises as an Architect.

When asked what he likes to do in his spare time, he replies, "I like to write and I like to code. I also like to write about code."

comments powered by Disqus