Getting a 'System.AccessViolationException' exception in C# using RightFax
I'm trying to send faxe开发者_StackOverflow社区s 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?
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.
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!
精彩评论