Page 1 of 1

WinForms utility application issue

PostPosted: Mon Feb 25, 2019 1:35 pm
by neil.interactit
Hi guys,

I have an external WinForms utility application that grabs work dockets from another system and creates invoices in Jiwa. The app references required Jiwa DLLs and then any Jiwa interaction within the app is via your business logic (eg. var debtor = new JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor(); debtor.ReadRecord(debtorId); etc). This is working well.

The client wants some changes. Even though the compiled exe continued to work when they upgraded to v175 , I am now unable to debug in the development environment.

I am getting:
Code: Select all
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=JiwaApplication
  StackTrace:
   at JiwaFinancials.Jiwa.JiwaApplication.Manager.HandleApplicationManagerPluginExceptions()
   at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, AuthenticationModes AuthenticationMode, String JiwaUserName, String JiwaPassword)
   at JobManager.JiwaService.GetJiwaUser() in C:\Users\neil\OneDrive\Documents\Projects\JobManagerOnly\JobManager\JiwaService.cs:line 73


Which is caused by the line:
Code: Select all
Manager.Instance.Logon(Properties.Settings.Default.Servername, Properties.Settings.Default.Database, database.AuthenticationModes.JiwaAuthentication, Properties.Settings.Default.Username, password);


I have confirmed all the passed parameters are not null, and neither is Manager.Instance, which appears in debug as:
Code: Select all
Manager.Instance
{JiwaFinancials.Jiwa.JiwaApplication.Manager}
    AppStylistRuntime: {Infragistics.Win.AppStyling.Runtime.AppStylistRuntime}
    ApplicationStylePath: ""
    ApplicationStyleProperties: {JiwaFinancials.Jiwa.JiwaApplication.Controls.StyleProperties}
    BusinessLogicCollection: {JiwaFinancials.Jiwa.JiwaApplication.BusinessLogic.BusinessLogicCollection}
    BusinessLogicFactory: {JiwaFinancials.Jiwa.JiwaApplication.BusinessLogicFactory}
    CommandLineArgs: null
    CompileDebugSymbols: true
    ConnectionProfile: {JiwaFinancials.Jiwa.JiwaApplication.ConnectionManager.ConnectionProfile}
    CrystalReportsProviderName: "SQLNCLI11"
    CurrentLogicalWarehouse: {Letitia Street / Hobart}
    CurrentLongRunningTask: null
    Database: {JiwaFinancials.Jiwa.JiwaODBC.database}
    DialogFactory: {JiwaFinancials.Jiwa.JiwaApplication.DialogFactory}
    FormFactory: {JiwaFinancials.Jiwa.JiwaApplication.FormFactory}
    Forms: {JiwaFinancials.Jiwa.JiwaApplication.Forms.FormCollection}
    GeneralLedgerConfiguration: {JiwaFinancials.Jiwa.JiwaApplication.GeneralLedger.Configuration}
    JLib: {JiwaFinancials.Jiwa.JiwaLib.StdFunctions}
    LicenceSQLConnection: {System.Data.SqlClient.SqlConnection}
    LicenceSQLTransaction: {System.Data.SqlClient.SqlTransaction}
    LocalCurrency: {JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency}
    LongRunningTasks: {JiwaFinancials.Jiwa.JiwaApplication.LongRunningTasks}
    MDIParentForm: null
    Menu: {JiwaFinancials.Jiwa.JiwaApplication.Menu.Menu}
    PhysicalWarehouseCollection: Count = 1
    PluginCollection: {JiwaFinancials.Jiwa.JiwaApplication.Plugin.PluginCollection}
    PluginFolder: "C:\\ProgramData\\\\JobManager\\1.0.0\\neil\\_localdb_MSSQLLocalDB\\InteractIT_V7\\Plugins\\admin"
    RecentItemCollection: {JiwaFinancials.Jiwa.JiwaApplication.RecentlyViewed.RecentItemCollection}
    ReportsFolder: "C:\\ProgramData\\\\JobManager\\1.0.0\\neil\\_localdb_MSSQLLocalDB\\InteractIT_V7\\Reports"
    Search: {JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch}
    Staff: {JiwaFinancials.Jiwa.JiwaApplication.JiwaStaff.clsStaff}
    SysDateTime: {25/02/2019 11:35:55 AM}
    SysLongDate: " ddd dd mmm yyyy hh:nn am/pm"
    SysShortDateCentury: "dd/MM/yyyy"
    TaxRates: {JiwaFinancials.Jiwa.JiwaApplication.JiwaTaxSystemRates.TaxRates}
    UsedLicences: Count = 1


I recall a similar issue with a previous Jiwa upgrade, and I'm thinking the fix is possibly unrelated to the obvious debug indication - maybe a framework version issue? - but I can't get a handle on it.

Can you assist?

Cheers,
Neil

Re: WinForms utility application issue  Topic is solved

PostPosted: Mon Feb 25, 2019 4:15 pm
by SBarnes
Do you have ALL jiwa dlls in the directory with the executable I have seen it fail at login due to a plugin that needed other Jiwa DLLs that were not related to the functionality I was using and as soon as I put all the DLLs in directory the problem went away?

Re: WinForms utility application issue

PostPosted: Tue Feb 26, 2019 8:43 am
by neil.interactit
That's done it! Thanks!

For others and future reference ... the project references 4 Jiwa DLLs ... JiwaApplication, JiwaODBC, JiwaSales and JiwaServiceManager ... and if I delete the bin/obj directories and rerun, I can see 89 Jiwa DLLs created in the bin folder ... so it looked like it was getting all "child" DLLs it needed. However, manually copying the other 207 DLLs into the bin folder did the trick.

Thanks again.

Re: WinForms utility application issue

PostPosted: Tue Feb 26, 2019 9:51 am
by Mike.Sheen
Also note that if you don't want to have a copy of the assemblies in your application folder - if Jiwa is installed already you can just add a handler for AppDomain.CurrentDomain.AssemblyResolve and in there direct .NET to go load the Jiwa assembly from a specific folder location.

This is discussed over in this forum thread: Late Binding or its Equivalent.

Re: WinForms utility application issue

PostPosted: Tue Feb 26, 2019 9:54 am
by SBarnes
Hi Mike,

Is there a reason why the DLLs are not registered in GAC?

Re: WinForms utility application issue

PostPosted: Thu Feb 28, 2019 11:02 am
by Scott.Pearce
General MS guidelines state not to install anything into the GAC if you don't really need to. Keeping things local also makes the deployment much simpler.

https://docs.microsoft.com/en-us/dotnet ... nd-the-gac