Try our conversational search powered by Generative AI!

Accessing Commerce Languages From CMS

Vote:
 

I'm trying to get a all the languages that are available in Commerce from CMS. I'm using 

Language.GetAllLanguagesDT().Rows

but I'm getting

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

every time I look to access it. Any suggestions would be greatly appreciated.

#72557
Jun 20, 2013 17:10
Vote:
 

Can you capture more info about exception? Like stack trace or something?

#72589
Jun 23, 2013 17:04
Vote:
 

Sorry for the late reply, but it was figured out. We had to do this:

DataCommand command = new DataCommand(); 
            command.ConnectionString = CoreConfiguration.Instance.Connection.AppDatabase; 
            command.CommandText = "[cms_LanguageInfoLoadAll]"; 
            command.Parameters = new DataParameters 
            { 
                new DataParameter("ApplicationId", AppContext.Current.ApplicationId, DataParameterType.UniqueIdentifier)  

            }; 

            DataTable loadTable = DataService.LoadTable(command);

DataRowCollection languages = loadTable.Rows;
Instead of calling
Language.GetAllLanguagesDT().Rows
Thanks for the reply.
#72656
Jun 25, 2013 17:57
Vote:
 

Sounds like AppContext or something similar was not initialized. You know - it's always better to dig till root cause, figure out what's the case, make adjustments, test and share the knowledge :)

#72661
Jun 25, 2013 20:13
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.