Newtonsoft.JSON hates me...

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Newtonsoft.JSON hates me...

Post by wjstarck » Sun Dec 08, 2019 11:16 am

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,)
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Newtonsoft.JSON hates me...

Post by cmcgehee » Mon Dec 09, 2019 7:44 am

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.
Chris McGehee
Open Dental Software
http://www.opendental.com

Post Reply