NullReferenceException: Object reference not set t

More
9 years 7 months ago - 9 years 7 months ago #654 by hex
I have a problem with I2 Localization plugin, this happens in 50% of the cases on my Mac machine and 100% on my Windows machine, I think that for some reason it doesn't get the system language. How can this be fixed? Thank you!


NullReferenceException: Object reference not set to an instance of an object
I2.Loc.LanguageSource.GetLanguageWithoutRegion (System.String Language) (at Assets/I2/Localization/Scripts/LanguageSource.cs:159)
I2.Loc.LanguageSource.AreTheSameLanguage (System.String Language1, System.String Language2) (at Assets/I2/Localization/Scripts/LanguageSource.cs:152)
I2.Loc.LanguageSource.GetLanguageIndex (System.String language, Boolean AllowDiscartingRegion) (at Assets/I2/Localization/Scripts/LanguageSource.cs:136)
I2.Loc.LanguageSource.TryGetTermTranslation (System.String term, System.String& Translation) (at Assets/I2/Localization/Scripts/LanguageSource.cs:220)
I2.Loc.LocalizationManager.TryGetTermTranslation (System.String Term, System.String& Translation, Boolean FixForRTL) (at Assets/I2/Localization/Scripts/LocalizationManager.cs:134)
I2.Loc.LocalizationManager.GetTermTranslation (System.String Term, Boolean FixForRTL) (at Assets/I2/Localization/Scripts/LocalizationManager.cs:119)
I2.Loc.Localize.OnLocalize () (at Assets/I2/Localization/Scripts/Localize.cs:124)
I2.Loc.Localize.OnEnable () (at Assets/I2/Localization/Scripts/Localize.cs:100)

I am using the latest version from the Asset Store with Unity 4.6.4 f1
Last edit: 9 years 7 months ago by hex.

Please Log in or Create an account to join the conversation.

More
9 years 7 months ago #655 by Frank
Hi,
From the line numbers in the callstack you are showing, it seems that at least one language in your LanguageSource has no name or is corrupted.
The call is failing when processing the string in mLanguages.Name at:
      if (AreTheSameLanguage(mLanguages[i].Name, language))

Can you verify that all languages in your source have a name (not empty) and a code?
Also, it could happen that you have more than one source (I2Languages.prefab + sources in your scene), if that's the case you have to double check them.

If the problem is that there is a corruption on your source, you could export the source to a CSV, delete all terms and languages in the source and reimport the CSV again. But before importing, open the CSV in excel o any other spreadsheet program and double check that there are not empty columns.
You could also export/import into google instead of to a local CSV.

If after doing that, you still get the problem, can you please send me a CSV file with a couple terms and all your languages to try reproducing this issue in here and send you a solution.

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
9 years 6 months ago - 9 years 6 months ago #822 by hex
It still happens. How can I send you an example of the languages?

Edit:

Solved it somehow.
I replaced the default language with "English" instead of "".

Last edit: 9 years 6 months ago by hex.

Please Log in or Create an account to join the conversation.

More
9 years 6 months ago #825 by Frank
Hi,
I'm glad that solved the issue for you.

But I'm curious to see what corruption is causing the original issue.
Can you please, from the language source in Unity, export the terms as a CSV file so that I could check if there is any other issue that could show later on for you.

You can send it to inter.illusion [at] gmail.com

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #1629 by walshmagger
NullReferenceException indicates that you are trying to access member fields, or function types, on an object reference that points to null. That means the reference to an Object which is not initialized.

SqlConnection connection = null;
connection.Open();

C# Interview questions

When you run this code, you will get :

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

The message "Object not set to instance of Object" means you are trying to use an object which has not been initialized.

You can avoid this error by coding like this:

if (connection != null)
{
connection.Open();
}

.Net Interview questions and answers

Note: In order to avoid this error you should always initialize your objects before you try to do anything with them.

Walsh

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #1631 by Frank
Although I think this post is from bot. Please @walshmagger correct me if I'm wrong!

This issue is from a year ago! Now there are lots of validations to make sure this null reference exception doesn't happen again.
Please update to the latest version if you are seeing a similar issue. And let me know if you are still having problems with the latest version!

Thanks!
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 8 years 4 months ago by Frank.

Please Log in or Create an account to join the conversation.

Time to create page: 0.170 seconds
Template by JoomlaShine