- Joined
- Jan 23, 2015
- Messages
- 10
- Reaction score
- 0
Hello,
I tried to upgrade my custom app to v15 but I get error on initialize of app.
I've done everything on sample project to connect.
Here is my code:
In addition, I'm using Topshelf library.
How should I solve this problem?
***
I can not connect even with the code below
I got the same error at .Root property.
I tried to upgrade my custom app to v15 but I get error on initialize of app.
System.DllNotFoundException: Unable to load DLL 'tcxpscom_native': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at TCX.Configuration.PhoneSystem.RegisterListener(MyPFN_UPDATE_LISTENER f)
at TCX.Configuration.PhoneSystem..ctor()
at TCX.Configuration.PhoneSystem.get_Root()
I've done everything on sample project to connect.
Here is my code:
Code:
class Connector3CXv15
{
static string instanceBinPath;
public static void Bootstrap()
{
try
{
var filePath = @"C:\Program Files\3CX Phone System\Instance1\Bin\3CXPhoneSystem.ini";
if (!File.Exists(filePath))
{
//this code expects 3CXPhoneSystem.ini in current directory.
//it can be taken from the installation folder (find it in Program Files/3CXPhone System/instance1/bin for in premiss installation)
//or this application can be run with current directory set to location of 3CXPhoneSystem.ini
//v14 (cloud and in premiss) installation has changed folder structure.
//3CXPhoneSystem.ini which contains connectio information is located in
//<Program Files>/3CX Phone System/instanceN/Bin folder.
//in premiss instance files are located in <Program Files>/3CX Phone System/instance1/Bin
throw new Exception("Cannot find 3CXPhoneSystem.ini");
}
instanceBinPath = Path.Combine(GetKeyValue("General", "AppPath", filePath), "Bin");
//AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Connect(filePath);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
public static bool Connect(string filePath)
{
{
var a = new Random(Environment.TickCount);
//unique name PhoneSystem.ApplicationName = "TestApi";//any name
PhoneSystem.ApplicationName = "Connector3CXv15" + a.Next().ToString();
}
#region phone system initialization(init db server)
var value = GetKeyValue("ConfService", "ConfPort", filePath);
var port = 0;
PhoneSystem.CfgServerHost = "127.0.0.1";
if (!string.IsNullOrEmpty(value))
{
int.TryParse(value.Trim(), out port);
PhoneSystem.CfgServerPort = port;
}
value = GetKeyValue("ConfService", "confUser", filePath);
if (!string.IsNullOrEmpty(value))
PhoneSystem.CfgServerUser = value;
value = GetKeyValue("ConfService", "confPass", filePath);
if (!string.IsNullOrEmpty(value))
PhoneSystem.CfgServerPassword = value;
#endregion
var dns = PhoneSystem.Root.GetDN(); //Access PhoneSystem.Root to initialize ObjectModel
//SampleStarter.StartSample(args);
//PhoneSystem.Root.Disconnect();
return PhoneSystem.Root.Connected;
}
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var name = new AssemblyName(args.Name).Name;
if (name == "3cxpscomcpp2")
return Assembly.LoadFrom(Path.Combine(instanceBinPath, name + ".dll"));
else
throw new FileNotFoundException();
}
[DllImport("kernel32.dll", EntryPoint = "GetPrivateProfileStringA")]
static extern int GetKeyValueA(string strSection, string strKeyName, string strNull, StringBuilder RetVal, int nSize, string strFileName);
static public string GetKeyValue(string Section, string KeyName, string FileName)
{
//Reading The KeyValue Method
try
{
StringBuilder JStr = new StringBuilder(255);
int i = GetKeyValueA(Section, KeyName, String.Empty, JStr, 255, FileName);
return JStr.ToString();
}
catch (System.Exception e)
{
throw e;
}
}
public static string GetParameterValue(string name, string DefaultValue, ref bool exists)
{
try
{
exists = true;
return TCX.Configuration.PhoneSystem.Root.GetParameterByName(name).Value;
}
catch
{
exists = false;
return DefaultValue;
}
}
}
In addition, I'm using Topshelf library.
How should I solve this problem?
***
I can not connect even with the code below
Code:
{
var a = new Random(Environment.TickCount);
PhoneSystem.ApplicationName = "Connector3CXv15" + a.Next().ToString();
}
PhoneSystem.CfgServerHost = "127.0.0.1";
PhoneSystem.CfgServerPort = 5485;
PhoneSystem.CfgServerUser = "cfguser_default";
PhoneSystem.CfgServerPassword = "z320xszg1lj";
var dns = PhoneSystem.Root.GetDN();
Last edited: