Getting a 'System.AccessViolationException' exception in C# using RightFax

2.2k Views Asked by At

I'm trying to send faxes through RightFax COM API Library:

  RFCOMAPILib.FaxServer server = new RFCOMAPILib.FaxServer();
  server.ServerName = "xxx";
  server.Protocol = CommunicationProtocolType.cpTCPIP;
  server.UseNTAuthentication = BoolType.True;

  // Error happens here
  server.OpenServer(); 

  RFCOMAPILib.Fax fax = (RFCOMAPILib.Fax)server.get_CreateObject(RFCOMAPILib.CreateObjectType.coFax);

  fax.ToName = "Batman";
  fax.ToFaxNumber = "23434484";
  fax.FromFaxNumber = "78678676";
  fax.FromName = "Robin";
  fax.Send();

I have registered the DLL file rfcomapi.dll:

C:\Program Files\RightFAX> RegSvr32 rfcomapi.dll     

Unfortunately, when running this code, I get the following error;

Unhandled Exception: system.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I'm using version 9.4.0.0 of RightFax.

How do I fix this problem?

2

There are 2 best solutions below

0
On BEST ANSWER

The problem was the server name was incorrect, since we couldn't resolve that name in our network. I pinged the server and I got nothing, however I got the IP address of it and it worked fine!

Always ping the server with RightFax! The error messages you are going to get are not very descriptive!

1
On

Your code itself is perfect. I can run it with my 9.4 RightFax without any problem. You may want to check with your authorization to make sure you account is full authorized in the server.