Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NullReferenceException: Object reference not set to an instance of an object. #179

Open
megahirt opened this issue Jan 20, 2022 · 4 comments
Assignees
Labels
S/R Exception S/R Exceptions under investigation

Comments

@megahirt
Copy link
Contributor

megahirt commented Jan 20, 2022

awa-flex

System.NullReferenceException: Object reference not set to an instance of an object.
  at LfMerge.Core.DataConverters.ConvertLcmToMongoLexicon.LcmWsToLfWs () [0x00048] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/DataConverters/ConvertLcmToMongoLexicon.cs:598
  at LfMerge.Core.DataConverters.ConvertLcmToMongoLexicon..ctor (LfMerge.Core.ILfProject lfProject, LfMerge.Core.Logging.ILogger logger, LfMerge.Core.MongoConnector.IMongoConnection connection, SIL.Progress.IProgress progress, LfMerge.Core.MongoConnector.MongoProjectRecordFactory projectRecordFactory) [0x00079] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/DataConverters/ConvertLcmToMongoLexicon.cs:65
  at LfMerge.Core.Actions.TransferLcmToMongoAction.DoRun (LfMerge.Core.ILfProject project) [0x00104] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/Actions/TransferLcmToMongoAction.cs:64
  at LfMerge.Core.Actions.Action.Run (LfMerge.Core.ILfProject project) [0x0010d] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/Actions/Action.cs:142
  at LfMerge.Core.Actions.SynchronizeAction.DoRun (LfMerge.Core.ILfProject project) [0x0038e] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/Actions/SynchronizeAction.cs:182
  at LfMerge.Core.Actions.Action.Run (LfMerge.Core.ILfProject project) [0x0010d] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge.Core/Actions/Action.cs:142
  at LfMerge.Program.RunAction (System.String projectCode, LfMerge.Core.Actions.ActionNames currentAction) [0x000f4] in /build/lfmerge-7000072-8UUe80/lfmerge-7000072-2.0.55.21/src/LfMerge/Program.cs:128 
@megahirt megahirt added the S/R Exception S/R Exceptions under investigation label Jan 20, 2022
@megahirt megahirt changed the title System.NullReferenceException: Object reference not set to an instance of an object. awa-flex System.NullReferenceException: Object reference not set to an instance of an object. Jan 20, 2022
@megahirt megahirt changed the title awa-flex System.NullReferenceException: Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. Jan 20, 2022
@josephmyers
Copy link
Collaborator

Not sure what exactly was null in this method, as the code has changed since the stacktrace. We could try to get the DLL's for v2.0.55.21 and look at the decompile, or we could null-proof the roughly 15 potentials in the method.

@josephmyers
Copy link
Collaborator

@rmunn Chris informed me of the multiple branches I needed to search that could apply to the stacktrace. I searched master, live, and fieldworks8-live, and none of them had a line 598 that could obviously throw a NullReferenceException. Any ideas on how to identify the correct line?

@megahirt
Copy link
Contributor Author

The assumption here is that this is FW9 code since the method is named "LcmWsToLfWs()". If it was FW8 code I assume it would have been named "FdoWsToLFWs()" or something similar.

So, we are looking at a NullReferenceException happening somewhere in the LcmWsToLfWs() method:

		private Dictionary<string, LfInputSystemRecord> LcmWsToLfWs()
		{
			// Using var here so that we'll stay compatible with both FW 8 and 9 (the type of these two lists changed between 8 and 9).
			var vernacularWSList = ServiceLocator.LanguageProject.CurrentVernacularWritingSystems;
			var analysisWSList = ServiceLocator.LanguageProject.CurrentAnalysisWritingSystems;

			var lfWsList = new Dictionary<string, LfInputSystemRecord>();
			foreach (var LcmWs in ServiceLocator.LanguageProject.AllWritingSystems)
			{
				var lfWs = new LfInputSystemRecord()
				{
					//These are for current libpalaso with SIL Writing Systems.
					// TODO: handle legacy WS definition
					Abbreviation = LcmWs.Abbreviation,
					IsRightToLeft = LcmWs.RightToLeftScript,
					LanguageName = LcmWs.LanguageName,
					#if FW8_COMPAT
					Tag = LcmWs.Id,
					#else
					Tag = LcmWs.LanguageTag,
					#endif
					VernacularWS = vernacularWSList.Contains(LcmWs),
					AnalysisWS = analysisWSList.Contains(LcmWs)
				};

				#if FW8_COMPAT
				lfWsList[LcmWs.Id] = lfWs;
				#else
				lfWsList[LcmWs.LanguageTag] = lfWs;
				#endif
			}
			return lfWsList;
		}

@josephmyers A null reference exception means that the code is trying to access a data property on a non-existent object, correct?

@megahirt
Copy link
Contributor Author

Since this issue occurred a long time ago, we need to re-verify that this is still a problem.

@josephmyers TODO:

  • verify that awa-flex is still on HOLD
  • if still on HOLD, take it off HOLD and re-do the S/R.
  • If the error persists, then debug it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S/R Exception S/R Exceptions under investigation
Projects
Development

No branches or pull requests

2 participants