0

I have Visual Studio 2008 Database Edition, and everything worked great until the first time I tried to load a .dbproj file. These database project files work for the other developers I work with, but when I try to open it, I just get an error message "Object reference ot set to an instance of an object."

Load dbproj

It's probably the same problem this guy is having, although he didn't do a good job of describing it and has no solution.

Every other kind of project file loads and builds and runs normally. dbproj files all generate this cryptic error. I just tried a fresh removal and reinstall of Visual Studio 2008 DE to no avail. Could this have something to do with my SQL 2005 installation? (This also works normally through SQL Server Management Studio.)

** UPDATE **

Probably even more importantly, this same error occurs when I try to make a new dbproj file. Every other type of project can be created no problem.

New dbproj

Community
  • 1
  • 1
Alain
  • 26,663
  • 20
  • 114
  • 184

2 Answers2

1

You need to tell Visual Studio the correct instance of SQL Server to use for validation.

Tools>Options>DatabaseTools

Change the settings in "Data Connections" and "Design-time Validation Database" to reflect the correct instance.

ml_black
  • 371
  • 1
  • 2
  • 10
  • Guess we edited this issue at the same time! Glad we solved it. – ml_black Jul 15 '11 at 14:51
  • As the member of my team that discovered the problem, you get the credit! – Alain Jul 15 '11 at 18:20
  • I'm having this problem today with Visual Studio 2010. However, when I go to Tools-->Options-->Database Tools I'm able to change it to the correct instance of SQL Server but I don`t have the "Design-Time Validation Database" option in VS2010. Is there anything else I can try? I'm able to open the project but I get the above error when I try to open a .sql file. – Ray May 11 '15 at 15:07
0

After many failed re-configurations and re-installations, a member of my team discovered the problem!

Under Tools > Options > Database Tools > Design-time Validation Database, there is an option to set your SQL Server Instance Name. Visual Studio automatically picks this when it's installed.

The key is that Visual Studio doesn't necessarily pick the right one. I happen to have 3 SQL server instances on my machine. SQLEXPRESS (a 2005 instance that Visual Studio installed alongside itself), SQLEXPRESS2005, a 2005 instance I installed, and SQLEXPRESS2008, which I also installed.

Visual Studio had configured itself to connect to the SQLEXPRESS2008 instance, even though it only supports SQL2005 dbproj files by default. By opening this dialogue, and updating the server instance name, the error no longer appeared and I was able to open dbproj files:

Solution

Alain
  • 26,663
  • 20
  • 114
  • 184