Hello,
I am currently trying to improve a custom service using the RightFax com api library. I followed some guides such as
http://rightfaxapi.com/wp-content/uploads/2013/03/IntegratingRightFax_Student-Guide.pdf
and http://rightfaxapi.com/wp-content/uploads/2013/03/OpenText_RightFax_10.5_COM-Reference_Guide.pdf
but I can't put my finger on the problem I have.
I wish to use events to process faxes in an auxiliary system. The thing is, events are never being fired and I can't figure out why.
Here is what I've tried to do in a side, test project just to make it work before completely integrating it in my solution.
Imports RFCOMAPILib
Module TEST
Private rfFaxAPI As FaxServer
Dim WithEvents MyFaxServerEventHandler As RFCOMAPILib.FaxServer
Dim EventsObj As RFCOMAPILib.Events
Private Const SERVER_NAME As String = "****"
Private Const USER_ID As String = "****"
Private Const USER_PASSWORD As String = "****"
Sub Main()
rfFaxAPI = New FaxServer
rfFaxAPI.ServerName = SERVER_NAME
rfFaxAPI.Protocol = CommunicationProtocolType.cpTCPIP
rfFaxAPI.AuthorizationUserID = USER_ID
rfFaxAPI.AuthorizationUserPassword = USER_PASSWORD
rfFaxAPI.UseNTAuthentication = BoolType.False
rfFaxAPI.OpenServer()
Dim user As User = rfFaxAPI.Users(xx)
Console.WriteLine("RightFax Server opened")
Console.WriteLine("Faxes: " & rfFaxAPI.Faxes(USER_ID).Count)
MyFaxServerEventHandler = rfFaxAPI
EventsObj = rfFaxAPI.Events
EventsObj.WatchValidateEvents = BoolType.True
EventsObj.WatchCompleteEvents = BoolType.True
EventsObj.WatchArchiveEvents = BoolType.True
EventsObj.WatchNewFaxes(user) = BoolType.True
EventsObj.WatchMessageEvents(MessageEventType.meCustom1) = BoolType.True
Console.WriteLine("Watching user : " & user.UserName)
Console.ReadLine()
rfFaxAPI.CloseServer()
End Sub
Private Sub MyFaxServerEventHandler_OnMessageEvent(ByVal NewMessageEvent As RFCOMAPILib.MessageEvent) Handles MyFaxServerEventHandler.OnMessageEvent
Console.WriteLine(DateTime.Now & ": MessageEvent fired")
End Sub
Private Sub MyFaxServerEventHandler_OnArchiveEvent(ByVal NewMessageEvent As RFCOMAPILib.ArchiveEvent) Handles MyFaxServerEventHandler.OnArchiveEvent
Console.WriteLine(DateTime.Now & ": ArchiveEvent fired")
End Sub
Private Sub MyFaxServerEventHandler_OnCompleteEvent(ByVal NewMessageEvent As RFCOMAPILib.CompleteEvent) Handles MyFaxServerEventHandler.OnCompleteEvent
Console.WriteLine(DateTime.Now & ": CompleteEvent fired")
End Sub
Private Sub MyFaxServerEventHandler_OnValidateEvent(ByVal NewMessageEvent As RFCOMAPILib.ValidateEvent) Handles MyFaxServerEventHandler.OnValidateEvent
Console.WriteLine(DateTime.Now & ": ValidateEvent fired")
End Sub
Private Sub MyFaxServerEventHandler_OnNewFaxEvent(ByVal NewMessageEvent As RFCOMAPILib.Fax) Handles MyFaxServerEventHandler.OnNewFaxEvent
Console.WriteLine(DateTime.Now & ": OnNewFaxEvent fired")
End Sub
End Module
I am able to connect to the server. I am able to retrieve how many faxes are currently in the queue. I can also send fax with another piece of code not shown above, but never in any of this is any event triggered.
The execution is never halted, but when i add breakpoints and look into some objects, here are the errors I usually find:
- System.IO.FileNotFoundException: The system cannot find the file specified. ({"The system cannot find the file specified.":Nothing})
- System.ArgumentException: The parameter is incorrect.
- System.Runtime.InteropServices.COMException: Cannot create another system semaphore.
Source is pretty much always mscorlib. I tried reinstalling .NET framework. I tried launching with previous versions (currently using 4.5.2) I tried changing rfcomapi library to anything i could find. I tried switching from VS2010 to VS2015. There seem to be core issues that are preventing the whole thing from working properly.
I forgot to mention, this is for a Rightfax 10.6 server. To force events, I manually add faxes in the RightFax FaxUtil with the correct user.
Any help would be greatly appreciated.
David