Link to home
Start Free TrialLog in
Avatar of Dm32z
Dm32z

asked on

Fax Module ActiveX DLL Server 2003

We have a legacy ASP web app that we have migrated to server 2003 STD.  All has gone well minus the fact that the fax module DLL does not work properly.  We have the source code and I realized it was using the old fax com object that is now the extended fax com object under 2003.  I have rebuilt the DLL a couple of times now using the extended com object but have had no luck.  I think it may also have to do with the fact that

1: I am coding the new DLL under VS2005 (.NET v2)
2: I'm not sure if there is anytthying in particular I have to do to make a DLL an ActiveX DLL.

It has been years since I have coded in any language and even then I wasn't really doing anything worth mentioning.  ;)  Any help would be greatly appreciated.  I am going to post the source from the original as maybe I am just going about this all the wrong way.

=================

Function SendDocByFax(FDoc, FServer, FNumRecip, FRecip, FNumSend, FCov, _
                        FFNumSend, FComp, FAddr1, _
                        FAddr2, FAddr3, FSend, _
                        FSubj, FNote) As String

    On Error GoTo Ferr
    Dim FaxServer As Object
    Dim FaxDoc As Object
    Dim faxStatus As String
   
   
    Set FaxServer = CreateObject("FaxServer.FaxServer")
    faxStatus = "Create Object"
   
    FaxServer.Connect (FServer)
    faxStatus = "FaxServer.Connect"
   
    Set FaxDoc = FaxServer.CreateDocument(FDoc)
    faxStatus = "CreateDocument"
   
    If FCov = True Then     'Decide if a coverpage will be sent
        FaxDoc.SendCoverpage = 1
    Else
        FaxDoc.SendCoverpage = 0
    End If
   
    If FAddr1 <> "" Then    'Iterate to send up to three address lines
        FaxDoc.SenderAddress = FAddr1 & Chr(13)
    End If
    If FAddr2 <> "" Then
        FaxDoc.SenderAddress = FaxDoc.SenderAddress & FAddr2 & Chr(13)
    End If
    If FAddr3 <> "" Then
        FaxDoc.SenderAddress = FaxDoc.SenderAddress & FAddr3
    End If
   
    FaxDoc.ServerCoverpage = 1  'Coverpage on server rather than client
    FaxDoc.CoverpageName = "OMS.cov"
    faxStatus = "Coverpage"
   
    FaxDoc.SenderCompany = FComp
    FaxDoc.SenderFax = FFNumSend
    FaxDoc.SenderOfficePhone = FNumSend
    FaxDoc.SenderName = FSend
    FaxDoc.CoverpageSubject = FSubj
    FaxDoc.CoverpageNote = FNote
    FaxDoc.RecipientName = FRecip
    FaxDoc.FaxNumber = FNumRecip
    FaxDoc.Send
    faxStatus = "Send"
       
    Set FaxDoc = Nothing
   
    FaxServer.Disconnect
   
    Set FaxServer = Nothing
    SendDocByFax = "OK"
   
Ferr:
    SendDocByFax = Err.Description & "  " & faxStatus
   
End Function

===============

Thanks!
Avatar of JohnBPrice
JohnBPrice

Well, for starters the Extended FAX object has changed names, it is not Set FaxServer = CreateObject("FaxServer.FaxServer"), but
Set FaxServer = CreateObject("FAXCOMEXLib.FaxServer"),

Furthermore, it will help coding easier if you use early binding instead of late binding, e.g.
Dim FaxServer As New FAXCOMEXLib.FaxServer

Here are the salient bits of code from one of my apps that uses the extended fax server.  I don't use all the parameters you need, but once you get the basics, you should be able to add in the rest.  Look to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/fax/faxinta_n_7e05.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/fax/faxinta_n_3md0_cpp.asp

Dim svrex As New FAXCOMEXLib.FaxServer
Dim FaxEx As FAXCOMEXLib.FaxDocument

                svrex.Connect "<Your server machine name>"

                Set FaxEx = New FAXCOMEXLib.FaxDocument

                FaxEx.Body = "<Your printable file name>" 'FDoc I presume
                FaxEx.DocumentName = "<Your printable file name>" 'This is so it shows up in the fax console with a nicer name

                FaxEx.Recipients.Add "<Your phone number with dialing codes>" , "<Pretty Name for REcip>"' FRecip, FNumRecip

                'If you want a reciept
                FaxEx.ReceiptAddress = "EmailAddress for receipt"
                FaxEx.ReceiptType = frtMAIL
                FaxEx.AttachFaxToReceipt = True
                FaxEx.ScheduleType = fstDISCOUNT_PERIOD 'I do this to control when the fax will be sent

                FaxEx.ConnectedSubmit svrex
                Set FaxEx = Nothing


Avatar of Dm32z

ASKER

Tell me what you think about what I did before, maybe I am just coding in the studio.  I'm thinking that my problems may be that I am using Visual Studio 2005 and it is compiling in .Net v2 and the ASP web app doesn't like it.  Can the extended COM object be used under VB 6?

Here is my code:

=================

   Function SendDocByFax(ByVal FDoc, ByVal FServer, ByVal FNumRecip, ByVal FRecip, ByVal FNumSend, ByVal FCov, ByVal FFNumSend, ByVal FComp, ByVal FAddr1, ByVal FAddr2, ByVal FAddr3, ByVal FSend, ByVal FSubj, ByVal FNote) As String

        On Error GoTo Ferr
        Dim objFaxDocument
        Dim objFaxServer
        Dim objSender As FaxSender.Class1
        Dim JobID As Object
        Dim faxStatus As String

        objFaxDocument = CreateObject("FAXCOMEX.FaxDocument")
        objFaxServer = CreateObject("FAXCOMEX.FaxServer")
        faxStatus = "Create Object"

        'Connect to the fax server
        objFaxServer.Connect(FServer)
        faxStatus = "Connected to Fax Server"

        'Set the fax body
        objFaxDocument.Body(FDoc)
        faxStatus = "Create Document"

        'Add the recipient with the fax number
        objFaxDocument.Recipients.Add(FNumRecip, FRecip)

        'Choose to attach the fax to the fax receipt
        objFaxDocument.AttachFaxToReceipt = False

        'Set the cover page type and the path to the cover page
        objFaxDocument.CoverPageType = 2
        objFaxDocument.CoverPage = "OMS.cov"

        'Provide the cover page note
        objFaxDocument.Note = FNote

        'Set Fax Subject
        objFaxDocument.Subject = FSubj

        'Set the sender properties.
        objFaxDocument.Sender.Name = FSend
        objFaxDocument.Sender.Company = FComp
        objFaxDocument.Sender.FaxNumber = FFNumSend
        objFaxDocument.Sender.OfficePhone = FNumSend
        objFaxDocument.Sender.StreetAddress = "123 Main Street"
        objFaxDocument.Sender.TSID = "Omega Home Builders fax daemon"

        'Iterate address lines
        If FAddr1 <> "" Then
            objFaxDocument.Sender.Address = FAddr1 & Chr(13)
        End If
        If FAddr2 <> "" Then
            objFaxDocument.Sender.Address = objFaxDocument.Sender.Address & FAddr2 & Chr(13)
        End If
        If FAddr3 <> "" Then
            objFaxDocument.Sender.Address = objFaxDocument.Sender.Address & FAddr3
        End If

        'Save sender information as default
        objFaxDocument.Sender.SaveDefaultSender()

        'Submit the document to the connected fax server
        'and get back the job ID.

        JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
        faxStatus = "Send"

        objFaxServer.Disconnect()
        SendDocByFax = "OK"


Ferr:
        SendDocByFax = Err.Description & "  " & faxStatus

    End Function

=======================

I understand what you are saying about binding, and I'll switch that.  Thanks.  Is there anything I need to do special to this VB code to make it able to work when called from an ASP web app?

Thank you for helping a code newb like me.  ;)
My fax app using the Extended FAX object is in VB6.  I haven't done it from .Net 2005, but I recall you must have interop compatibility turned on to use ActiveX com objects, and probably want to add them as a reference to your project.  


What kind of errors do you get?
Avatar of Dm32z

ASKER

Sorry for the slow response.  Here is the error code I get:


error '800401f9'


The line of code in the ASP that calls the function is:

================
    arrName = Split(Request.Form("fnName"),"||")
    arrFax = Split(Request.Form("fnFax"),"||")
    Set objFax = CreateObject("FaxSender.Class1")
    For i=1 To UBound(arrName)
      rc = objFax.SendDocByFax(phyFile,Application("srvName"),arrFax(i),arrName(i),sPh,cvr,SFax,SCo,SA1,SA2,SA3,SName,Request.Form("rdtSubj"),Request.Form("rdtMessage"))
      If rc <> "OK" Then
      errStatus = True
      Exit For
      End if

================

Thank you.
Ha, 800401F9 has one of the most useless descriptions, "Error in the DLL."

Does it work if you call it from a non-ASP app?

About the only thing I could suggest is to start your DLL in the debugger and step through it to find what is causing the problem.
Avatar of Dm32z

ASKER

Ok, I got past all those initial issues.  I hadn't imported the library.  Now though I'm getting a new error.  Am I right in my thinking that since I'm coding in visual studio 2005 (.net ) I don't need to register the DLL.  Cause when I attempt to it tells me it can't create the entry point.  The error I'm getting now is:


=====================

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'FaxSender.Class1'

=====================


Any help is greatly appreciated.  Thanks.
800a01ad is the COM DLL is missing components.  Are you getting this error on your development machine?

>>I don't need to register the DLL
If you compile on the machine, you don't need to.  If you deploy on a different machine, you do need to have the .net framework installed and Interop libraries on the target computer (they are needed to wrap the .net DLL in an ActiveX component)  see http://msdn2.microsoft.com/en-us/library/fh1h056h(VS.80).aspx

You also need to check "Register for COM interop" in the .net project compile settings, but I believe you already did that or you wouldn't be this far.  see also http://msdn2.microsoft.com/en-us/library/kew41ycz(VS.80).aspx and http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx



>>when I attempt to it tells me it can't create the entry point.

The DLL created by .net is not a COM dll but a .net managed code library, the Interop libraries wrap the dll to make it work like a COM dll, but as you found out, you can't register the dll itself.
Avatar of Dm32z

ASKER

I read through the articles.  Can you give me an example of what they are after, I don't think I'm grasping it.  Bare with me as I said I am newbish. ;)
Basically they describe how .Net Interop supports COM interfaces, although I haven't done much of that, my understanding is
A) .Net has to be installled on your target computer.
B) The resulting DLL is NOT an ActiveX dll, but a .net assembly
C) There are things you can do in .Net that will not work in COM, such as polymorphic interfaces,  e.g. in .net you can have the same method name with different parameter lists, but not in COM
D) When you choose "Register for COM Interop", you will get a .tlb you can use as the type library in ActiveX languages.

I believe you may also have to use the regasm tool in .net once on the target computer to let the interop libraries know what .net dll to register as COM.  If you look in the registry for a .net COM Interop, you will find that the the dll registered is not actually the dll you built, but one of the .net dlls, and there are extra parameters that tell that dll where to find your dll.

Are you getting the error on your development machine or a deployment machine?
Avatar of Dm32z

ASKER

Deployment.  The dev machine sadly is just me with VS 2005.  I don't have the entire ASP app on my machine.  I know this would probably make it easier to say.  I have however now found the option inside VS 2005 and have the tlb file.  And your saying I need to to what with it.  Also on these files it makes in the /bin folder after I recompile.  Maybe I'm not putting those in the right location on the deployment machine.  

The files are:

FaxSender.dll
FaxSender.tlb  (just now got that one)
FaxSender.xml
fxscomexLib.dll




My question I'm wondering is of those files, what all have to go over to the deployment machine.  Does the fxscomexLib.dll need to also go?  Inside my project it is tagged as copy local so that makes me think it does not.  Does the xml need to move over as well?  Also on the fxscomexLib.dll file, if it does need to get copied over, does it need to be in the same file structure location as it is in the project references.  I sure do appreciate all the help!
>>Deployment

Ok, that makes more sense.  Whip up a little app on your machine to test that it does work under ASP and save some headaches.

For the deployment machine, have a look in your registry to find your class library, then look on the target machine to see if it has the same entries.  If it is missing on the target machine (assuming it has .net already installed and the same release level as you), use the regasm tool to register your .net dll.  Regasm lives withing the windows folder.  Use the /tlb switch.  It basically is the same as regsvr32, but for com interop .net dlls  do "regasm youdll.dll /TLB"
with the appropriate paths of course.

>>Maybe I'm not putting those in the right location on the deployment machine.  
That is what regasm is for, it defines the location.
BTW, fxscomexLib.dll  IS an ActiveX dll, and thus gets registered in the normal way I think.
Avatar of Dm32z

ASKER

Ok, I moved over the four files and used the regasm to register my .net dll.  fxcomexLib.dll gives me the same entry point message with i try to register.  I am still getting the same message when i try to run in from within the asp app.  I'm going to see if I can work up something in asp to make sure I am not just fighting a losing battle here.  


After I did the Regasm which came back successful was there anything else I needed to do.  Thanks for the help.  
>> fxcomexLib.dll gives me the same entry point message with i try to register.

Now I'm wondering if the problem is not your control, but the fax client itself.  I've not tried to manually register it, I usually go to the machine and add the fax server as a printer.  Perhaps there is some other setup that the faxserver client must do that you are not doing.  So that is worth a try.

>>I'm going to see if I can work up something in asp to make sure I am not just fighting a losing battle here.  
It is always a good idea to make sure your stuff works in a test environment before deploying.
Avatar of Dm32z

ASKER

On the test machine I am getting this in the event log.  It could be my asp code causing it as well.


Failed to execute request because the App-Domain could not be created. Error: 0x80131902
Did you try installing the fax-printer on your local machine too?  Can you send a fax?
Avatar of Dm32z

ASKER

I moved the entire project back to VB 6.  I have the DLL compiled and with error checking and log files now have the DLL going all the way to the connect submit where it litterally just times out.  The command that runs but just sits there is:

JobID = objFaxDocument.ConnectedSubmit(objFaxServer)



Once it submits the asp just sits and eventually times out.  Never even drops to the error code.  
Avatar of Dm32z

ASKER

I can see that notepad.exe fires up under the Network Service, but never closes and the DLL just hangs.
Avatar of Dm32z

ASKER

Yea that is pretty much what happens.  I have reinstalled fax services, but it keeps doing the exact same thing.  I have also stubled across other posts on the internet with this issue, but yet to have any resolutions.  It is like it works and as soon as it submits, fires up notepad to read the document it hangs while notepad is open.  Eventually the asp calling the DLL times out.  Any help is greatly appreciated.  
The fax client uses the app associated with the file suffix that you attach as the fax body.  I believe it uses the "print" action for the file association, just as double-clicking the file uses the "open" action, e.g. it does nearly the same thing as right-clicking on a document and choosing "Print" instead of open.  It "prints" to a special printer drive that converst it into a TIF, which the fax server uses for all faxes.  Since it is opening notepad, I assume you are attaching a text document.  

Can you fax the same document using the fax-printer from your machine?  

Can you right click the source document and choose "print", it should go to your default printer when you click on it.

Can you send a different document type?  Like Excel or Word?
Avatar of Dm32z

ASKER

Does the fax printer off the server need to be installed on all client machines that will use the asp app?
>>Does the fax printer off the server need to be installed on all client machines that will use the asp app?

Yes.  It might be possible to install it and then remove it, however, if you don't want them to see it.  I never tried that.  Or install it as administrator.
Avatar of Dm32z

ASKER

I have installed the printer on the client stations but still having the exact same issue.  I send the job and notepad it fired up on the server and just sits there.  
Can you use the fax printer on the client station to fax?  e.g. not using your app, just testing that the fax services work?
Avatar of Dm32z

ASKER

Yes.
ASKER CERTIFIED SOLUTION
Avatar of JohnBPrice
JohnBPrice

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dm32z

ASKER

I scrapped down my code to just send the test text file and even hard coded in the number and name into the DLL.  Regardless all it does is just call up notepad and sit there.  I keep thinking there is something in the enviroment that is leading to this as I keep coming across other posts on the net with people having this same issue.  All this box has on it is SQL & IIS.  Other then that it is a fresh box.  
Avatar of Dm32z

ASKER

If I take out the document call then it will send a cover page only just fine.  
My fax server is running SQL & IIS also, but no problems.  I do not fax text documents, mostly pdf's.
Avatar of Dm32z

ASKER

Is it also 2003?  Maybe I am having some sort of rights issue.  I'm going to try a pdf and see if it is just maybe the text file problem.
Yes 2003 server.
Avatar of Dm32z

ASKER

You have certainly answered my question I began with it has just snowballed into many more issues.  I have come across 6 other instances on the net of people having the exact same issue now as I.  I want to go ahead an award you the points you have most certainly earned.  I'm going to start a new post on this specific final issue I am having in the hopes someone mite have an idea or a direction to go to attach it.  Thank you for all your patient and knowledge.