With more and more customers using our SDKs, we've started to receive bug reports that happen when two or more apps from different vendors are trying to access the same Medialooks' DLLs on a single system. This post contains a step-by-step guide and video for resolving this issue.
At Medialooks we are big adopters of COM, which is the most commonly used technology on the Windows platform. Every COM DLL has to be registered in the Windows Registry: it is not possible to simply copy the application's files to a new system and run the app - an installation procedure has to be in place (see our current redistribution guidelines) and may require Administrator rights.
Also, there can't be two versions of the same library registered at the same time - the application will automatically use the DLL that was registered most recently. Because of this, when 2 or more MPlatform-based applications end up on one system, the following situations may occur:
- Application A is installed on a computer; and application B is installed later. Both applications use the same set of DLLs from MPlatform SDK. Application B, when installed, will register its own set of DLLs, and application A will be forced to use these DLLs because of the nature of the COM model. If application B uses older versions of the DLLs, application A may crash or have issued because it is designed to work with newever versions of the DLLs.
- Application A is installed on a computer. Later, a trial version of application B is installed. At some point the user decides to uninstall application B, which leads to the DLLs being unregistered and deleted. This will lead to permanent damage to application A - it will not work until installed again.
Fortunately, there is a solution: Side-by-side assembly (also known as WinSxS or SxS). It allows applications to use their own manifests to specify which DLLs they want to use and removes the necessity to register these DLLs.
In addition to removing the conflicts, you will be able to move your app from folder to folder or run in from a flash drive, external hard disk or DVD without any kind of setup or installation process.
In this walkthrough we will show an easy 3-step way to make a registration-free C# application that uses our COM libraries. Instead of registering a component on a computer, we will create a Win32-style manifest file that contains information about binding and activation. This manifest, rather than registry keys, will take care of activation of all COM objects. We will use our Advanced Playlist Sample from MPlatform SDK as an example (by default it is installed to C:\Program Files (x86)\Medialooks\MPlatform\Samples Advanced\C#\Playlist Sample).
Step 1: change project preferences
The first thing we need to do is to tell Visual Studio not to embed manifest into executables (we want to use our own). Go to Playlist Sample / Properties / Application and set Manifest dropdown to Create application without a manifest. Now, rebuild your project (let's assume that we are building it for the x86 platform).
Step 2: copy the files
- Copy your application and required DLLs to C:\Program Files (x86)\Medialooks\MPlatform\Samples Advanced\C#\Playlist Sample\bin\x86\Debug\DLLs. Check this article to find out what dlls you should redistribute with your application.
- Place C:\Program Files (x86)\Medialooks\MPlatform\Bin\Manifests\x86\MServer.exe.manifest near the MServer.exe .It should be located in three places:
C:\Program Files (x86)\Medialooks\MPlatform\Samples Advanced\C#\Playlist Sample\bin\x86\Debug\DLLs\
C:\Program Files (x86)\Medialooks\MPlatform\Samples Advanced\C#\Playlist Sample\bin\x86\Debug\DLLs\DecoderLib\
C:\Program Files (x86)\Medialooks\MPlatform\Samples Advanced\C#\Playlist Sample\bin\x86\Debug\DLLs\EncoderLib\
Step 3: generate manifest
Now we need to generate a manifest for the Playlist Sample.exe. The easiest way to do this is to run our custom application: C:\Program Files (x86)\Medialooks\MPlatform\Utilities\ManifestMaker.exe. You need to select a path to Playlist Sample.exe in the upper field there and the manifest will be generated automatically and placed near Playlist Sample.exe.
You can also create this manifest manually without our utility: take a prototype manifest from ..\Bin\Manifests\x86\[YourApplicationExeFile].exe.manifest and rename it according to your application's .exe file name (Playlist Sample.exe.manifest in our case).
That's it. Now you can run "Playlist Sample.exe", and it will execute correctly regardless of whether the DLLs are registered or not.
All advanced samples from MPlatform SDK contain "Test_Isolated_x86.bat" and "Test_Isolated_x64.bat" files which perform the steps above and allow you to run those samples in registration-free mode.
Here's also a quick video that explains this situation and guides you through the process: