spMFUpdateAssemblies

Returns
Parameters
@MFilesVersion nvarchar(100) (optional)
  • Retained for backward compatibility and logging only.

  • No longer determines the Interop DLL file path.

  • If NULL, MFSettings.MFVersion is read for logging purposes.

  • If provided, MFSettings.MFVersion is updated to this value (informational).

@Debug int (optional)
  • Default = 0

  • 1 = Standard Debug Mode

  • 101 = Advanced Debug Mode

Purpose

Drop, reload, and recreate all CLR assemblies and procedures.

Additional Info

This procedure is compiled during installation and can only be used in the target database.

As of 2026-04-22: Interop.MFilesAPI.dll is resolved dynamically at runtime (Change 8):

  • If M-Files client is detected in the registry (HKLM\SOFTWARE\Motive\M-Files), the procedure locates Interop.MFilesAPI.dll from the client install path - Bin\X64\ for M-Files 26.1+, Common\ for earlier versions. This prevents GAC signature mismatches that occur when a bundled DLL differs from the version registered in the Windows GAC by the M-Files client installer.

  • If M-Files client is not installed, or its folder has no Interop.MFilesAPI.dll: falls back to AssemblyInstallPath (the MFSQL assemblies folder). Interop.MFilesAPI.dll must then be copied there by hand; the installer does not place it there (see below).

MFInstallPath is no longer used for Interop DLL path resolution.

The path of the Interop.MFilesAPI.dll loaded at the last successful reload is recorded in MFSettings.MFilesInteropPath, and the detected client version in MFSettings.MFVersion.

What the installer places in the assemblies folder

The Release 5.13.38.82 installer copies three files to the assemblies folder (MFSettings.AssemblyInstallPath, for example C:\MFSQL\Assemblies\):

  • Laminin.Security.dll

  • LSConnectMFilesAPIWrapper.dll

  • LSConnectMFilesAPIWrapper.XmlSerializers.dll

It does not copy Interop.MFilesAPI.dll. On a SQL Server with the M-Files client (M-Files Desktop) installed, which the installation requires, that is the expected content of the folder: the procedure loads the client’s own copy. Laminin.Security.dll must be present in the folder, or the procedure stops with “Unable to install Assemblies, check access to filelocation, run installation on SQL Server.”

When Interop.MFilesAPI.dll is not found

If the DLL is neither in the M-Files client folder nor in the assemblies folder, the procedure raises an error (severity 16) with the text “Interop.MFilesAPI.dll not found at: <path>. If M-Files client is installed, verify the M-Files installation is intact. Otherwise copy Interop.MFilesAPI.dll to the assemblies folder (<folder>) and re-run spMFUpdateAssemblies.”, records a failed row in MFDeploymentDetail and returns -1. The assemblies are not reloaded. The CLR procedures, which the procedure drops in its first step, are not recreated, so every procedure that calls M-Files fails until spMFUpdateAssemblies completes. Repair or install the M-Files client, then run the procedure again.

How do I find the installed version

-- Highest connector release installed in this database (for example 5.13.38.082)
SELECT dbo.fnMFLastConnectorVersion();

-- Deployment history: wrapper version and procedure release, Interop assembly
-- version and M-Files version, who ran it and when
SELECT TOP 5 * FROM dbo.MFDeploymentDetail ORDER BY DeployedOn DESC;

-- M-Files version and the Interop.MFilesAPI.dll path used at the last reload
SELECT Name, Value FROM dbo.MFSettings WHERE Name IN ('MFVersion', 'MFilesInteropPath');

A row in MFDeploymentDetail whose LSWrapperVersion starts with “Failed” records a reload that did not complete.

WMI Event Alert (Integration Connector). An automated WMI alert deployed by 35.703.job.CreateMFilesUpdateAlert.sql (shipped in the Integration Connector bundle) detects M-Files version changes within seconds and calls this procedure to reload assemblies. The script runs automatically during install and upgrade and can be re-run manually in SSMS against the MFSQL application database. On servers with multiple MFSQL application databases, run the script once per database.

On SQL Server Express installations - where no SQL Server Agent is available - the WMI alert is not created. Call this procedure manually after every M-Files upgrade.

Use @MFilesVersion to record a specific M-Files version in MFSettings (useful to correct an erroneous version or for logging purposes).

Examples

To update the assemblies based on the MFVersion in MFSettings

EXEC dbo.spMFUpdateAssemblies;

To update the assemblies with a different MFVersion or manually update the assemblies

EXEC dbo.spMFUpdateAssemblies @MFilesVersion = '19.8.8082.5';

Roadmap

  • M-Files client no longer required - a later release is planned to run without the M-Files client on the SQL Server.

  • CLR-to-API migration - longer-term: eliminate the CLR dependency entirely by migrating to direct M-Files REST/gRPC API calls.

Changelog

Date

Author

Description

2026-11-16

AC

Keep only the customer-facing roadmap items

2026-11-16

AC

Document the assemblies folder content, the not-found error, return values and how to read the installed version

2026-04-22

AC

Dynamic registry detection for Interop.MFilesAPI.dll path (Change 8)

2026-03-25

AC

Load Interop.MFilesAPI from AssemblyInstallPath; remove MFInstallPath dependency

2021-10-07

LC

add spMFGetFilesInternal, spMFGetHistory

2021-04-01

LC

Get master db owner and set DB to default owner

2020-11-10

LC

test that all the clr procedures have been dropped

2020-11-10

LC

prevent assemblies to be deleted

2020-10-27

LC

Refine error messages and logging

2019-09-27

LC

Add MFilesVersion parameter with default

2019-01-11

LC

IF version in mfsettings is different from installer then use installer add parameter to set MFVersion

2019-01-09

LC

Add additional controls to validate MFversion, exist when not exist.

2018-09-27

LC

Add control to check and update M-Files version. This is to allow for the CLR script to be able to be executed without running the app.

2017-07-25

LC

ADD SETTING TO SET OWNER TO SA

2017-05-04

DevTeam2

Added new parameter DeleteWithDestroy

2016-09-26

DevTeam2

Removed vault settings parameters and pass them as comma separated string in VaultSettings parameter.

2016-03-10

LC

Created