Sage 50 2014 COM

I developed an windows application using VS 2005 in XP with COM, and it has been working fine, but when I try to develop the same functionality in an windows application using VS 2010 in Windows 7, COM reference "PeachTree Accounting 21.0 Type Library" is not listed in Add Reference Dialog box under COM tab. I could add the reference by browsing and selecting Interop.Peachwserver.dll from Sage 50 2014 program folder installed. Then I run the program, it throws an error at LogIn.GetApplication (Sage 50 is opened at this point). I use the same 3rd party name and password. Is there anything that needs to be changed in VS 2010?

  • 0

    You may need to go into the properties for your project and change the target cpu to x86.

  • 0 in reply to wood

    Target CPU is already set to x86, so that does not seem to be the problem. How about the target framework? It is currently set to .Net Framework 4.0.

  • 0 in reply to bh_db

    I investigated it more, and found that it was registry issue. I still have an error FileNotFoundException thrown at LogInSelector (Sage 50 gets opened and can continue debugging though).

  • 0 in reply to bh_db

    I get the following error message at LogInSelector

    Creating an instance of the COM component with CLSID {49073E6E-C47A-41DD-BF5A-01184439577C} from the IClassFactory failed due to the following error: 8007007e.

    And the following error message at GetApplication.

    Unable to cast COM object of type 'System.__ComObject' to interface type 'PeachtreeAccounting.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0D1B3BD7-7E9E-49D5-941B-53C6A30553AF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

  • 0 in reply to bh_db

    The first error looks as though your attempting to login without Sage50 being open, you can bypass this and it will attempt to open the application, but you'll have to login again.

    The second looks like your application may be referencing the wrong version of Interop.PeachwServer.dll. If it's missing from the COM reference list in Visual Studio you can browse to it and add it manually. It will be located in the Peachtree program files folder.

  • 0 in reply to wood

    I added Interop.PeachwServer.dll manually from Browse tab, but I get the same error. I tried to re-register the dll by regsvr32 command, but it gives me an error:"dll is loaded, but the entry-point 'DllRegisterServer' was not found".

  • 0 in reply to bh_db

    Did you ever get past this issue, I am struggling with a similar issue using the ManagedCOM. I need to create a PurchaseInvoice in Sage from a .net application. I am getting a similar error message when calling the TOPurchaseInvoice.SaveAll method.

    System.invalidCastException:Unable to cast COM object of type 'System_ComObject' to interface type 'Interop.PeachW.Server.Application' This operation failed because the QueryInterface call on the COM component......

    Any help you can provide is greatly appreciated!! We also just recently upgraded to Sage 50 2015. This error is popping up after that upgrade, We were able to CreatePurchaseInvoice with the 2014 version. Our .net application had not changed. Thanks for any direction or help on this!

  • 0 in reply to epic69

    We have this issue on only one of our development machines. I am not sure if this helps, but the problem seems to be solved by changing registry. In our case, the registry key had 8.3 name in the path to the dll file, and the issue is solved by changing it to the actual path. PeachTree Accounting 21.0 Type Library showed up in COM list in Add Reference dialog, and the error at GetApplication was resolved. The error at LogInSelector was still thrown after changing the registry, but it is resolved by opening Sage 50 before LogInSelector is called. The machine with the issue does not have 8.3 name assigned to Program Files folder where Sage 50 is installed.