Work Around SQL Packager Retirement

muzmuz Posts: 6 New member
Hi there,

We bought a license to upgrade our SQL Data Compare from version 7 to version 13.

All of the code involved in the upgrade has been completed, except for updating RedGate.SQLPackager.Engine.dll. I saw the retirement note of this dll in your website, so we decided to stick to the existing dll as recommended.

Having followed your recommendation though, we have another dependency issue - see below for more details:

Existing code:
        PackagerEngine engine = new PackagerEngine(
                   ......,
                   .......,
                   .......,
                   m_SchemaBlock,//of type RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock
                   m_DataBlock,//of type RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock
                   .......,
                   .......);

Upgraded code:
        PackagerEngine engine = new PackagerEngine(
                   ......,
                   .......,
                   .......,
                   m_SchemaBlock,//of type RedGate.SQLCompare.Engine.IExecutionBlock
                   m_DataBlock,//of type RedGate.SQLCompare.Engine.IExecutionBlock
                   ......., 
                   .......);


As you may have already guessed, the upgraded code fails as the constructor of 'PackagerEngine' expect a variable of type RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock, whereas the new upgraded code changes this to the new reference, which is RedGate.SQLCompare.Engine.IExecutionBlock.

Please let me know what your recommendation is to workaround this issue.

Kind regards,
Muzafar Mahgoub


Tagged:

Answers

  • muzmuz Posts: 6 New member
    Can someone please look into my query above?

    Regards, Muz
  • Alex BAlex B Posts: 1,043 Diamond 4
    edited July 25, 2018 12:45PM
    Hi @muz,

    I believe you will need to explicitly cast the IExecutionBlock as an ExecutionBlock using one of the following:
     Work work = new Work();
    ExecutionBlock block = work.ExecutionBlock as ExecutionBlock;
    or 
    Work work = new Work();
    ExecutionBlock block = (ExecutionBlock))work.ExecutionBlock;
    Please give this a try and let me know if you are still running into an issue.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • muzmuz Posts: 6 New member
    Thanks Alex B for getting back to me.

    You said: "I think Jess is right..."
    I can't see any message from Jess or anyone, just the message you sent above. I hope I am not missing answers to my question somewhere in the site.

    With regards to the suggestion above, this still doesn't work unfortunately as the property method (named ExecutionBlock) of the upgraded Work object (now provided by the assembly RedGate.SQLCompare.Engine.Deployment) returns an interface of type 
    RedGate.SQLCompare.Engine.IExecutionBlock, rather than RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock (which is expected by the constructor of the old/retired PackagerEngine)

    So when I come to cast the IExecutionBlock, I will be casting of type RedGate.SQLCompare.Engine.ExecutionBlock instead of RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock, which brings the same issue - please see code sample below for clarity:

    Work work = new Work();
    ExecutionBlock block = (RedGate.SQLCompare.Engine.ExecutionBlock) work.ExecutionBlock;

    So now when I go:

    PackagerEngine engine = new PackagerEngine(
                       ......,
                       .......,
                       .......,
                       block,
                       ......., 
                       ......., 
                       .......);

    I get the error:
    "Argument type 'RedGate.SQLCompare.Engine.ExecutionBlock' is not assignable to parameter type 'RedGate.Shared.SQL.ExecutionBlock.ExecutionBlock' "

    I hope this makes sense.

    Please help!

    Muz
  • muzmuz Posts: 6 New member
    Can someone please have a look at the above query please?

    Thanks, Muz
  • Alex BAlex B Posts: 1,043 Diamond 4
    Hi @muz,

    Apologies for that, it was a copy error from my internal notes that I forgot to remove when putting here - I have edited the post above.

    I have asked the development team if there is a way around this with the latest version of the SDK, though it looks very much like this is going to require using an older version of the SDK.

    I will update when I have further information.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • muzmuz Posts: 6 New member
    Thanks for getting back to me Alex.

    Yes this is one of the things I tried to do to follow your casting recommendation. I down-graded the assembly of the Work class to satisfy the type. But I found that the assembly I down-graded depends/links on another old assembly, so I down-graded that too, and this happened again. I ended up reverting back all of my original dlls (so reverted the application back to version 7).

    Please let me know if there is a way around this issue.

    Regards, Muz
  • Alex BAlex B Posts: 1,043 Diamond 4
    Hi Muz,

    Unfortunately there is not a way around this for using the dlls in this manner.  One of the reasons (or perhaps outcomes) of retiring Packager is so that breaking changes could be made to the Comparison SDK.  You will need to stick with the older versions to utilize this method.

    I've also just realized that you are on Data Compare v13, which would be SQL Data Compare itself rather than the Comparison SDK (which was retired at v12) so you should not be using the dll's from version 13.

    The official workaround is to use the command lines instead of the SDK - documentation and a download link for the script packaging utility command line can be found at https://documentation.red-gate.com/display/SQP8/SQL+Packager+8+documentation

    I hope this helps clarify how things should work!

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.