AppDomain.Unload hangs when using PelcoSDK.dll version 3.3.1
I have a Pelco DX4800 recorder and I am using the Pelco SDK version 3.3.1 as instructed by Pelco tech support.
I am using Visual Studio 2013 on Windows 7.
1. I have a created a C++ dll called PelcoSDKAdapterNative.dll which links to the PelcoSDK.lib file.
2. I have created a C++ CLR wrapper dll called PelcoSDKAdapterClr.dll which references the PelcoSDKAdapterNative.dll file above.
3. I have a C# program which attempts to load the PelcoSDKAdapterClr.dll file above using an AppDomain like so:
public class LoadDlls : MarshalByRefObject
public void LoadDll(string file)
Assembly assembly = Assembly.LoadFile(file);
if (assembly != null)
string result = "Dll loaded successfully - log this..blah blah";
string result = "Failed to load Dll - Log this..blah blah";
static void Main(string args)
AppDomainSetup info = new AppDomainSetup();
Assembly arAssembly = typeof(LoadDlls).Assembly;
info.ApplicationBase = Path.GetDirectoryName(arAssembly.Location);
AppDomain appDomain = AppDomain.CreateDomain("LoadDlls", null, info);
if (appDomain != null)
ar = (LoadDlls)appDomain.CreateInstanceAndUnwrap(arAssembly.FullName, typeof(LoadDlls).FullName) as LoadDlls;
AppDomain.Unload(appDomain); <-- The program will hang here forever
appDomain = null;
I notice 2 things happening:
1. When the call to Assembly assembly = Assembly.LoadFile(file); is executed the following 2 files are created in C:\ProgramData\Pelco\SDK
2. When AppDomain.Unload(appDomain); is executed the program simply hangs forever and never continues execution.
I suspect this is because the PelcoSDK.dll is starting up a thread to monitor for recorders and is never released.
How can I solve this problem?
Hello. Normally, we would recommend that you update to the latest version of the SDK, but the DX4800 is no longer supported.
Privacy and Cookies Policy
Copyright © Pelco