Red Gate forums :: View topic - Compare Database throws NullReferenceException
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK 10
SQL Comparison SDK 10 forum

Compare Database throws NullReferenceException

Search in SQL Comparison SDK 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
MarkLFT



Joined: 22 Apr 2011
Posts: 10
Location: Bali, Indonesia

PostPosted: Sat May 04, 2013 7:56 am    Post subject: Compare Database throws NullReferenceException Reply with quote

I have a Windows Service application, that runs continuously. The app will check for differences between two databases, and the syncs the changes from DB2 to Db1.

We use the DataCompare SDK to do this.

The service will run for days, sometimes weeks with no problem. But then without warning, it will throw a NullReferenceException on the command

session.CompareDatabases(db1, db2, mappings);

If I restart the service it will sometimes go away, sometimes it will come back immediately. Other times the problem will fix it self after a couple of hours. But then reoccur a few hours later.

The job runs every few minutes, and is identical in its settings for every run. So I find it confusing that we would get these errors so intermittently.

Can you please offer any advice, on how I can pint down the route cause.

To help I have attached a Stack trace from one of the errors.

Code:
#8ZK.#7ZK #pmc(String #A2Tb, String #K12b, String #aLPb, Boolean #NMrc):330
#8ZK.#pmc #89K(String #1Z, String #y0, FieldPair #M9rc, Boolean #N9rc):97
#8ZK.#pmc #89K(IComparable #WfVb, IComparable #H12b, FieldPair #M9rc, Boolean #N9rc, Boolean #O9rc):397
RedGate.SQLDataCompare.Engine.ResultsStore.Store IdenticalValues(Object value1, Object value2, FieldPair fieldPair, Boolean forceBinaryString, Boolean roundDoubles, Boolean treatEmptyStringAsNull):434
RedGate.SQLDataCompare.Engine.ComparisonSession #paL(Int32 #39rc, Object[] #09rc, Object[] #19rc, IList`1 #49rc, DifferencesSummary #59rc, Byte[] #29rc, Boolean #N9rc, Boolean #O9rc, Boolean #69rc):17
RedGate.SQLDataCompare.Engine.ComparisonSession #maL(#H1K #X9rc, #H1K #Y9rc, TableMapping #3Krc, ProgressPercentageTracker #luPb):0
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings, SessionSettings sessionSettings, Boolean doNotBeDefeated):1570
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings, SessionSettings sessionSettings):0
RedGate.SQLDataCompare.Engine.ComparisonSession CompareDatabases(Database db1, Database db2, TableMappings mappings):0
D:\_My Projects\Resort Manager\Dev\ResortManager\Utility Apps\RedGateWrapper\RedGateWrapper\SQLDataCompare.cs:190 in `SynchronizeData(IList`1 tableNames, SelectionDelegateType delegateType, TableMappingsType mappingsType, MappingOptions mappingOptions, Boolean applyWhereClause)`


[/code]
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6640

PostPosted: Mon May 06, 2013 3:19 pm    Post subject: Reply with quote

Hello,

It's hard to say from the stack trace, but it looks like something to do with collations or not knowing what the collation of the database is. Depends on if you are comparing scripts, or scripts to live databases, or something in the code. Scripts folders should have the table schema and the RedGateDatabaseInfo.xml file which should set the collation.

Or you could bypass the whole issue and use the option to do a binary comparison, but then it compares text case-sensitively and including white space and you may not want that.

Like with all null-ref exceptions, you want to debug and look at the local variables to see if anything is set to null and if those variables are being used. So the stack trace is part of the troubleshooting but I can't draw any definitive conclusions from it.
Back to top
View user's profile Send private message
MarkLFT



Joined: 22 Apr 2011
Posts: 10
Location: Bali, Indonesia

PostPosted: Mon May 06, 2013 3:29 pm    Post subject: Reply with quote

Hi,

We are not comparing to scripts, we are comparing a database tables with another database tables.

In the command CompareDatabases() there are only three parameters, db1, db2, and mapping. I have checked these and the are not null, I also checked the properties of these three objects, and none of the properties are null.

With regards to going further into the stack trace, as you can see, all the methods have been obfuscated. I am guess by you guys.

I will check the collation settings, but I am sure they are the same on both servers.

Thanks
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6640

PostPosted: Wed May 08, 2013 3:40 pm    Post subject: Reply with quote

I can decode the stack frames at my end and the method names do point towards a problem with collations.

If you don't have any joy, I'll email you a link to our debugging tool and that may help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group