Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

A couple questions regarding .NET sync scripts, downloads only for now. Supporting information below.

  • Are constructors with a DBConnectionContext still supported? (I’ve spotted no information in what’s new changed behavior documentation)
  • If not, what is the alternate means of getting the connection context in an event?
  • If so, any particular magic configuration to make MLServer recognize the non-default constructor?

We are trying to add some .NET synchronization scripts to our working SQL script implementation under SA 12.0.1. Our initial bare bones assembly is loading into the correct AppDomain, and when the handle_download event fires, ML Server attempts to instantiate the class and call the correct method.

If we use a default constructor, the class instantiates, but then we have no reference to the DBConnectionContext. If we add the connection context to the constructor, we get:

E. 2011-12-21 11:31:11. <1> [-10161] No valid constructor was found for class 'MlSync.DownloadStream.Download'
E. 2011-12-21 11:31:11. <1> [-10225] Failure occurred while executing user supplied code in the server
I. 2011-12-21 11:31:11. <1> Synchronization failed

A newsgroup post from Feb 2010 suggests no parameters are allowed in the constructor, yet all the documentation shows examples like:

public class AuthClass {
    private DBConnection  _conn;

    /// AuthClass constructor.
    public AuthClass(DBConnectionContext cc) {
        _conn   = cc.GetConnection();

Our actual class follows the same pattern:

public class Download
    private readonly DBConnectionContext _dbConnectionContext;
    private readonly ServerContext _serverContext;

    public Download(iAnywhere.MobiLink.Script.DBConnectionContext cc)
        _dbConnectionContext = cc;
        _serverContext _dbConnectionContext.GetServerContext();

In an earlier spike under SA 10.0.1, this formulation worked, but it is failing now under SA 12. We do know the assembly is loading properly both because the correct path is referenced in the ML Server logs, and because we can log our own text to the server logs when using the default constructor.

asked 21 Dec '11, 17:36

Ron%20Emmert's gravatar image

Ron Emmert
accept rate: 12%

It should work. Most of our tests accept a DBConnectionContext object in the constructor. Could you post your server command line, please?

(21 Dec '11, 18:49) Bill Somers

It is apparently a deployment problem. When it was failing, iAnywhere.MobiLink.Script.dll was also copied to the deployment folder. When we deleted it and only included our own assembly, everything suddenly started working.

Since the logs show the assembly was being loaded from the GAC anyway, I don't know why this was a problem, but I'm not going to argue with success.

NOTE: key diagnostic was to type the constructor parameter as object and check what we got when attaching with the debugger.

public Download(object context)
    _dbConnectionContext = context as DBConnectionContext;
permanent link

answered 21 Dec '11, 18:35

Ron%20Emmert's gravatar image

Ron Emmert
accept rate: 12%

edited 21 Dec '11, 18:41

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 21 Dec '11, 17:36

question was seen: 2,634 times

last updated: 21 Dec '11, 18:49