Page 1 of 1

Newtonsoft.JSON hates me...

Posted: Sun Dec 08, 2019 11:16 am
by wjstarck
Another issue with Newstonsoft.JSON in the Middle Tier:

I get:

Code: Select all

InvalidCastException: [A]Anesthesia.AnesthPreference cannot be cast to [B]Anesthesia.AnesthPreference. Type A originates
 from 'Anesthesia19.3, Version=19.3.7281.23673, Culture=neutral, PublicKeyToken=null' in the context 'Default' at
 location 'C:\Users\wjs\Desktop\ODVersions\opendental19.3\opendental19.3\OpenDental\bin\Debug\Anesthesia19.3.dll'.
 Type B originates from 'Anesthesia19.3,Version=19.3.7281.23673, Culture=neutral, PublicKeyToken=null' in the context
 LoadNeither' at location 'C:\Users\wjs\Desktop\ODVersions\opendental19.3\opendental19.3\OpenDental\bin\Debug\Anesthesia.dll'.

Here:

Code: Select all

		public static void Update(AnesthPreference anesthPref, bool toggleAllPrefs) {
			if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),anesthPref,toggleAllPrefs); <---------------
				return;
			}
            string command = "REPLACE INTO anesthpreference(PrefNum,TimeStandard,TimeMilitary,VersionNum,AutoSaveMins,
            +FixToothGrphc,FixPhoneOnRx,SplitNotes,ElimDupNotes,ProcNoteLock,DynChartRefresh,
            +ChartRefInterval,DynApptBookRefresh,AddBackupMenuItem,AddEnhancedMenuItems,ToggleAllPrefs) VALUES('1', '"
            + POut.Bool(anesthPref.TimeStandard) + "'"
            + ", '" + POut.Bool(anesthPref.TimeMilitary) + "'"
            + ", '" + POut.String(anesthPref.VersionNum) + "'"
            + ", '" + POut.Int(anesthPref.AutoSaveMins) + "'"
            + ", '" + POut.Bool(anesthPref.FixToothGrphc) + "'"
            + ", '" + POut.Bool(anesthPref.FixPhoneOnRx) + "'"
            + ", '" + POut.Bool(anesthPref.SplitNotes) + "'"
            + ", '" + POut.Bool(anesthPref.ElimDupNotes) + "'"
            + ", '" + POut.Bool(anesthPref.ProcNoteLock) + "'"
            + ", '" + POut.Bool(anesthPref.DynChartRefresh) + "'"
            + ", '" + POut.Int(anesthPref.ChartRefInterval) + "'"
            + ", '" + POut.Bool(anesthPref.DynApptBookRefresh) + "'"
            + ", '" + POut.Bool(anesthPref.AddBackupMenuItem) + "'"
            + ", '" + POut.Bool(anesthPref.AddEnhancedMenuItems) + "'"
            + ", '" + POut.Bool(anesthPref.ToggleAllPrefs) + "'" + ")";
			DataCore.NonQ(command);
		}
As a reminder, I have to have multiple versions of my plugin in the OD folder (Anesthesia.dll, Anesthesia 19.2.dll, Anesthesia19.3 dll etc,)

Re: Newtonsoft.JSON hates me...

Posted: Mon Dec 09, 2019 7:44 am
by cmcgehee
To fix this, you probably will have to make sure that just the Anesthesia19.3.dll is in your bin folder on the Middle Tier server. I believe that when IIS loads an application, it will load every assembly in the bin folder, so having multiple Anesthesia dlls will likely cause problems when it comes to serialization.