locked
FAXCOMEXLib in Vista and XP RRS feed

  • Question

  • Hi,

    I'm creating faxes programmatically in C# using the FAXCOMEXLib dll.  Everything works fine but I've recently moved my development from an XP machine to Vista and now I'm running into a problem compiling.  I'm using the IFaxServerNotify_OnOutgoingJobChangedEventHandler interface to monitor changes to the submitted jobs which works in XP but in Vista the interface has changed to IFaxServerNotify2_OnOutgoingJobChangedEventHandler (note the 2).  For whatever reason, access to the original interface also doesn't exist in the Vista DLL.

    The problem is that if I make the change and compile in Vista, it works fine for Vista but if my application is installed on an XP box, that interface doesn't exist and I get a fatal exception if that code gets run.  However, if I compile on XP it will work for both XP and Vista machines.

    I've seen a number of potential ways to solve the problem on the internet but most of them are pretty complex and involved doing relinking and recompiling of the interop wrapper that gets generated and stuff like that.  I'm looking for something simpler.  I'm a bit confused as to why the old interface wouldn't be available in Vista so I'm wondering if there's a hotfix or some way to make it available again so I can compile in Vista with the old interface.

    Any help would be appreciated.
    Wednesday, September 9, 2009 5:05 PM

Answers

  • Try it like this:

                IFaxServer pFaxSrv = new FaxServerClass();
                pFaxSrv.Connect(Environment.MachineName);
                pFaxSrv.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE);
                IFaxServerNotify_Event events = (IFaxServerNotify_Event)pFaxSrv;
                events.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler(OnOutgoingJobChanged);


    Hans Passant.
    • Marked as answer by Kristofor Tuesday, September 15, 2009 8:20 PM
    Tuesday, September 15, 2009 7:09 PM

All replies

  • No, I definitely still see the original IFaxServerNotify interface when I look at it with Object Browser.  As well as IFaxServerNotify2.  Breaking COM interfaces is a great crime that Microsoft would be very hesitant to commit.

    Not sure why you wouldn't see it.  You can get a second opinion by running OleView.exe at the Visual Studio Command Prompt.  View + Type Library and select c:\windows\system32\fxscomex.dll

    Hans Passant.
    • Marked as answer by liurong luo Monday, September 14, 2009 3:55 AM
    • Unmarked as answer by Kristofor Tuesday, September 15, 2009 2:54 PM
    Wednesday, September 9, 2009 7:41 PM
  • You are right now that I look at the problem again, I apparently wasn't thinking correctly when I put the initial question up.  Here is the line of code in my source file I'm talking about:

    pFaxSrv.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler(OnOutgoingJobChanged);

    Compiling In XP, this works fine.  If I try and compile this in Vista I get the following compile error:

    "No overload for 'OnOutgoingJobChanged' matches delegate 'FAXCOMEXLib.IFaxServerNotify_OnOutgoingJobChangedEventHandler'"

    So the problem is actually on the other side.  The FaxServer class has an OnOutgoingJobChanged event that in XP takes the IFaxServerNotify interface and in Vista takes IFaxServerNotify2 interface instead.

    I apologize for the mix-up, it was one of those mornings.  In any case, the problem remains.  I can't compile the code on Vista and have it run successfully on an XP machine, while the reverse seems to work properly.


    Wednesday, September 9, 2009 8:24 PM
  • I'll have to guess at this, you posted not nearly enough code.  Don't create an instance use FaxServer, it implements the IFaxServer2 and IFaxServerNotify2_Event interfaces on Vista.  Create an instance of FaxServerClass and assign it to an IFaxServer variable.
    Hans Passant.
    Wednesday, September 9, 2009 9:04 PM
  • Sorry I wasn't trying to be cryptic.  There isn't really much more code that is relevant to this problem.  Here's the rest from this setup step:

     
     FaxServerClass pFaxSrv = new FaxServerClass();
     pFaxSrv.Connect(Environment.MachineName);
    
     //Register to listen for fax outqueue events and set the event handlers for our sever
     pFaxSrv.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE);
    
     pFaxSrv.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler(OnOutgoingJobChanged);

    Here is what I tried based on your suggestion and maybe you can point out what I did wrong because it didn't work:

    IFaxServer pFaxSrv = new FaxServerClass();
    pFaxSrv.Connect(Environment.MachineName);
    
    //Register to listen for fax outqueue events and set the event handlers for our sever
    pFaxSrv.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE);
    
    pFaxSrv.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler(OnOutgoingJobChanged);

    The result was an error stating that IFaxServer doesn't contain a definition for OnOutgoingJobChanged.  I sort of get what you're talking about, I need to access the old interface instead of the new one, but I'm not clear on how I can do that.


    Wednesday, September 9, 2009 9:26 PM
  • I'm still looking for anyone who has an example of compiling code on a Vista machine using the IFaxServerNotify interface that runs correctly on both XP and Vista machines. 
    Tuesday, September 15, 2009 2:57 PM
  • Try it like this:

                IFaxServer pFaxSrv = new FaxServerClass();
                pFaxSrv.Connect(Environment.MachineName);
                pFaxSrv.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE);
                IFaxServerNotify_Event events = (IFaxServerNotify_Event)pFaxSrv;
                events.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler(OnOutgoingJobChanged);


    Hans Passant.
    • Marked as answer by Kristofor Tuesday, September 15, 2009 8:20 PM
    Tuesday, September 15, 2009 7:09 PM
  • Thank you, this worked perfectly (well after a few other adjustments to other parts of the code).  I really appreciate the help!
    Tuesday, September 15, 2009 8:21 PM