Renaming by refactoring causes "Object Reference not set to an instance of an object" error
Hello, when I try to rename a column by refactoring the way described in http://msdn.microsoft.com/en-us/library/aa833295.aspx
a Msg-Box comes up telling me "Object Reference not set to an instance of an object".
It doesn`t matter wether the column I try to refactor is referenced by any other object, as I created a table
for testing purpose (which is not referenced by any object) with same result.It also doesn`t matter if I select or unselect any of the options:
Preview changes check box.
Assume default project schema dbo for unqualified script and unit test references check box.
Update references in schema objects containing warnings or errors check box.
Generate refactoring log check box.
I found out that this only happens if I try a renaming in a Databaseproject, which has a couple of files (perhaps this might be a reason?):Tables 213 Files
Keys 633 Files
Constraints 453 Files
Indexes 153 Files
Programmability 903 Files
Views 94 Files
Security 7
Schemas 5
Roles 1
Users 1
Storage 2
Files 2
Service 1The project is valid, I can "compile" it i.e. the model can written to the .dbschema file.
My next experiment was to create a new Databaseproject, importing a DB with one table and trying to refactor its columns.
Everything worked fine ... :|I`m working with:
...
Microsoft Visual Studio Team System 2008 Database Edition GDR
Microsoft Visual Studio Team System 2008 Database Edition GDR Version 9.1.40413.00
...Thanks for any advice
Answers
Hi,
Would you please check if you have scripts in pre/post-deployment script files? Or, do you have plain script files in the project that are marked 'not in build'? Rename refactoring also tries to look at these script files, which sometimes are problematic.
Is it possible to send us your project (or just part of your project that repro's this issue)?
Thanks,
Joyce- Proposed As Answer byJoyceWang_MSFTMSFTWednesday, November 04, 2009 4:46 PM
- Marked As Answer byEdwer FangMSFT, ModeratorThursday, November 05, 2009 2:27 AM
Joyce you seem to be right: I figure out the error is caused by a script which is marked as NotInBuild:
<NotInBuild Include="Scripts\Setup\SetupScripts\SourcingDB\90_00_cdc_enable_db_table.sql">
<SubType>NotInBuild</SubType>
</NotInBuild>
The script registers tables for CDC and modfies the Jobs created by CDC registration by using SQLCMD-Vars.
I can send you the script if you are interessted for debugging.
@Gert: Tracing didnt´t work for me. I set TraceToLogFile and TraceToDebugOutput to 1, but there hasn´t been created a folder "%APPDATA%\\Microsoft\\VisualStudio\\9.0\\VSTSDB" - Traces to DebugOutput works, but didnt`t deliver any info regarding this problem.
My settings:
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\VSTSDB\Tracing]
"TraceSwitch"=dword:00000000
"EventIdsToTrace"=dword:0001ffff
"PrefixTime"=dword:00000001
"PrefixPid"=dword:00000001
"PrefixThreadId"=dword:00000001
"TraceToDebugOutput"=dword:00000001
"TraceToLogFile"=dword:00000001
"LogDir"="%APPDATA%\\Microsoft\\VisualStudio\\9.0\\VSTSDB\\Trace"
"UniqueLogFile"=dword:00000001
"DisplayCallStack"=dword:00000000
Thanks a lot for your support :)- Marked As Answer byEdwer FangMSFT, ModeratorThursday, November 05, 2009 2:27 AM
All Replies
- Only way to diagnose this is to turn on tracing, repeat the operation that causes the error and check the trace output.
See the following to articles:
http://dbproj.com/Tutorials/tabid/62/TID/3/cid/26/Default.aspx
http://dbproj.com/Tutorials/tabid/62/TID/8/cid/26/Default.aspx
To help configure tracing.
GertD @ www.DBProj.com Hi,
Would you please check if you have scripts in pre/post-deployment script files? Or, do you have plain script files in the project that are marked 'not in build'? Rename refactoring also tries to look at these script files, which sometimes are problematic.
Is it possible to send us your project (or just part of your project that repro's this issue)?
Thanks,
Joyce- Proposed As Answer byJoyceWang_MSFTMSFTWednesday, November 04, 2009 4:46 PM
- Marked As Answer byEdwer FangMSFT, ModeratorThursday, November 05, 2009 2:27 AM
Joyce you seem to be right: I figure out the error is caused by a script which is marked as NotInBuild:
<NotInBuild Include="Scripts\Setup\SetupScripts\SourcingDB\90_00_cdc_enable_db_table.sql">
<SubType>NotInBuild</SubType>
</NotInBuild>
The script registers tables for CDC and modfies the Jobs created by CDC registration by using SQLCMD-Vars.
I can send you the script if you are interessted for debugging.
@Gert: Tracing didnt´t work for me. I set TraceToLogFile and TraceToDebugOutput to 1, but there hasn´t been created a folder "%APPDATA%\\Microsoft\\VisualStudio\\9.0\\VSTSDB" - Traces to DebugOutput works, but didnt`t deliver any info regarding this problem.
My settings:
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\VSTSDB\Tracing]
"TraceSwitch"=dword:00000000
"EventIdsToTrace"=dword:0001ffff
"PrefixTime"=dword:00000001
"PrefixPid"=dword:00000001
"PrefixThreadId"=dword:00000001
"TraceToDebugOutput"=dword:00000001
"TraceToLogFile"=dword:00000001
"LogDir"="%APPDATA%\\Microsoft\\VisualStudio\\9.0\\VSTSDB\\Trace"
"UniqueLogFile"=dword:00000001
"DisplayCallStack"=dword:00000000
Thanks a lot for your support :)- Marked As Answer byEdwer FangMSFT, ModeratorThursday, November 05, 2009 2:27 AM
Glad to know that you figured it out.
Would you please send me the not-in-build script? My MS alias is ywang. We are never too busy to check out those problematic scripts!
Thanks,
Joyce


