Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 (Français) » MobiLink - Server Administration » MobiLink server APIs » Writing synchronization scripts in .NET » Loading shared assemblies

 

Loading assemblies

A .NET assembly is a package of types, metadata, and executable code. In .NET applications, all code must be in an assembly. Assembly files have the extension .dll or .exe.

There are the following types of assemblies:

  • Private assemblies   A private assembly is a file in the file system.

  • Shared assemblies   A shared assembly is an assembly that is installed in the global assembly cache.

Before MobiLink can load a class and call a method of that class, it must locate the assembly that contains the class. MobiLink only needs to locate the assembly that it calls directly. The assembly can then call any other assemblies it needs.

For example, MobiLink calls MyAssembly, and MyAssembly calls UtilityAssembly and NetworkingUtilsAssembly. In this situation, MobiLink only needs to be configured to find MyAssembly.

MobiLink provides the following ways to load assemblies:

  • Use -sl dnet ( -MLAutoLoadPath )   This option only works with private assemblies. It sets the path to the application base directory and loads all the assemblies within it.

    When you use the -MLAutoLoadPath option you cannot specify a domain when entering the fully qualified method name for the event script.

    When you specify a path and directory with -MLAutoLoadPath, MobiLink does the following:

    • sets this path as the application base path

    • loads all classes in all files ending with .dll or .exe in the directory that you specified

    • creates one application domain and loads into that domain all user classes that do not have a domain specified

    Assemblies in the global assembly cache cannot be called directly with this option. To call these shared assemblies, use -MLDomConfigFile.

  • Use -sl dnet ( -MLDomConfigFile )   This option works with both private and shared assemblies. It requires a configuration file that contains domain and assembly settings. You should use this option when you have shared assemblies, when you don't want to load all the assemblies in the application base path, or when for some other reason you need to use a configuration file.

    With this option, MobiLink reads the settings in the specified domain configuration file. A domain configuration file contains configuration settings for one or more .NET domains. If there is more than one domain represented in the file, the first one that is specified is used as the default domain. (The default domain is used when scripts do not have a domain specified.)

    When loading assemblies, MobiLink tries to load the assembly first as private, and then attempts to load the assembly from the global assembly cache. Private assemblies must be located in the application base directory. Shared assemblies are loaded from the global assembly cache.

With the -MLDomConfigFile option, only assemblies that are specified in the domain configuration file can be called directly from event scripts.

 Sample domain configuration file