1

I am using Julmar ATAPI for creating an application which allows answering and making calls via TAPI. It was running well for most PhoneSystems. But with 3CX I get an exception when calling:

tapi = new TapiManager("AwesomeApp");
tapi.Initialize();
tapi.Lines[cbLines.SelectedIndex].Open(MediaModes.All);
line = tapiManager.Lines[cbLines.SelectedIndex];
line.MakeCall(tbPhoneNumber.Text);

The MakeCall-Line throws the following exception:

Name: ObjectDisposedException
Source: mscorlib
Site: Void DangerousAddRef(Boolean ByRef)
Message: Das SafeHandle wurde geschlossen. //The SafeHandle has been closed.
StackTrace:    bei System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   bei System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   bei JulMar.Atapi.Interop.NativeMethods.lineGetCallStatus(HTCALL hCall, IntPtr lpCallStatus)
   bei JulMar.Atapi.TapiCall.GatherCallStatus()
   bei JulMar.Atapi.TapiCall..ctor(TapiAddress addrOwner, UInt32 hCall)
   bei JulMar.Atapi.TapiAddress.MakeCall(String address, Int32 countryCode, MakeCallParams param)
   bei System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   bei System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   ...

I am clueless by now as this problem does not occur on Swyx, NFON and bintec elmeg as tested so far.

I've found this post referred by an issue of the ATAPI Project, but I don't quite understand what needs to be done for the fix and I get the feeling, that the intention was to create an own MakeCall funcion? At least I have not seen any ATAPI-Calls. The Application is a x64 deployment on a x64 client.

Now...even though I have not got much more code to provide, and a reproducable Example is probably almost impossible as this might even be client-dependent thing, I hope you could give me some hints on what is happening in the background which might cause this error. Is this a bug inside ATAPI? Is this a Problem caused by the TAPI-Provider? Is this a Problem I can fix in my code?

EDIT: Incoming calls seem to work...So why is this only happening during MakeCall? EDIT2: According to the Line-Capabilities MakeCall is supported.

Thank you very much in advance!

Devin
  • 11
  • 2
  • Do *not* ignore the return value of Initialize(). When you [get false](https://github.com/markjulmar/atapi.net/blob/31327dbbc33e2e5e44f4b54b65515fdd0110f205/src/src/TapiManager.cs#L152) then nothing good is going to happen next. – Hans Passant Jul 09 '21 at 16:08
  • @HansPassant Ah right! Thanks for that advice! I've added a check now. But in this case it returns true as it should. Incoming calls seem to work aswell.... – Devin Jul 12 '21 at 07:32
  • TAPI does not give you just the PBX but all TAPI devices known on your system (like WAN Miniport). Also not all commands are supported on all devices (like Voicemail ports). So sanity check 1: make sure you have the right device. Sanity check 2, examine the capabilities of the device to make sure it is capable of lineMakeCall (like does it have LINEADDRCAPFLAGS_DIALED and LINEADDRFEATURE_MAKECALL flags) – Kris Vanherck Jul 12 '21 at 07:43
  • @KrisVanherck I'm not quite sure wether I checked correctly. ATAPI.dll seems to only provide Lines and Addresses together with their capabilities. No Devices specifically. But Checking the Line capabilities with a LineWatcher (https://www.tapimaster.eu/en/en_tools_linewatcher.html) and ATAPI.dll showed that MakeCall is supported. That's also the reason why this behaviour suprises me so much... – Devin Jul 14 '21 at 12:46
  • OK, lets try narrowing down the suspects. I suggest 3 test: (1) try using another TAPI function on line object (like lineForward) to see if it is specifically lineMakeCall that fails this way or everything. (2) add a sleep/delay of a few second between the line open and makecall (it should not fail like this, but maybe something is "not ready" yet). (3) see if other tools (like julmar phone.exe) can do a lineMakeCall in the same situation If they also fail, the problem may be with the TSP or PBX. You could also get a slightly different error with more useful info. – Kris Vanherck Jul 16 '21 at 05:17
  • @KrisVanherck Thanks for your comment! So: 1) Forward seems to not be supported looking at the line-capabilities. Opening the line obviously works though. Not sure what other methods I could test. 2) I did. The user needs to click onto a button to start a makecall. And waiting did not fix it. 3) Won't work through the TapiMaster LineWatcher either (No error message). Dialer.exe only sais, that the line is already used by another program. – Devin Jul 23 '21 at 10:38

0 Answers0