Sql Server Parser dll versioning issue

Category: sql server smodmo

Question

MatClothier on Tue, 13 Aug 2013 12:51:47


Hi, I've been using the Microsoft.SqlServer.Management.SqlParser.dll to parse some sql queries

On my dev machine i have version 11.0.3000.0 (visible from the file properties of the dll) referenced for this project and i have that version in my GAC (In this version the int value of LEX_END_OF_LINE_COMMENT in the Tokens Enum is 626.)

on our CI server the GAC has version 11.0.2100.60 of the file (in this version the int value of LEX_END_OF_LINE_COMMENT in the tokens Enum is 603.)

It appears that both of these files have the same assembly version of 11.0.0.0 which is causing me issues as in our compiled code using the new dll version we're trying to compare the token int that comes back from scanner.GetNext() with Tokens.LEX_END_OF_LINE_COMMENT

e.g.        

var token = scanner.GetNext(ref state, out start, out end, out isPairMatch, out isExec);

if((Tokens) token == Tokens.LEX_END_OF_LINE_COMMENT)
{
//Do some things
}

which gets compiled down to:

var token = scanner.GetNext(ref state, out start, out end, out isPairMatch, out isExec);

if((Tokens) token == 626) { //Do Some Things }


When we execute the code on the CI server we actually get back 603 from Scanner.GetNext(); as dot.net is loading the wrong sqlparser.dll from the GAC because the assembly versions are the same even though the enum values have changed

Is there any way around this? it seems to me that releasing a different version of this dll without changing the assembly version is the cause of this issue?

Many thanks



Replies

Allen Li - MSFT on Thu, 15 Aug 2013 06:59:48


Hi MatClothier,

Thank you for your question. 

I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 

Thank you for your understanding and support.

If you have any feedback on our support, please click here.

Christian HL - MSFT on Thu, 15 Aug 2013 08:18:55


Hi,

I think the only way is to either downgrade the feature pack version on your dev machine or upgrade the one at your CI server.

Olaf Helper on Thu, 15 Aug 2013 08:52:20


Other option: Mark the assembly (reference) as local copy, then your app works with a copy from your dev machine instead of the one from GAC.

See How to: Set the Copy Local Property of a Reference and CopyLocal Property (Reference Object)

danturn on Fri, 16 Aug 2013 11:35:54


Hi Olaf, 

We have tried that, it still looks in the GAC first due to strong naming.

danturn on Fri, 16 Aug 2013 11:41:15


Hi Christian, 

Unfortunately although i can resolve this on our CI server, the end user target machines for our product are not in a controlled environment so while we can fix this on our build it doesn't solve the potential issues on client machines

We just need to be able to include a specific version of the dll to reference and always use that local dll.