Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesConfused about GetHostSettingsConfused about GetHostSettings
Previous
 
Next
New Post
3/9/2011 6:48 PM
 
In my code file I am getting conficting information.
If I use: Common.Globals.HostSettings - I get: Obsolete use: Host.GetHostSettingDictionary
When I use Host.GetHostSettingDictionary it claims it is not a member of Host.
When I check the object browser I find DotNetNuke.Entities.Host.HostSettings.GetHostSetting
If I use DotNetNuke.Entities.Host.HostSettings.GetHostSetting this is now obsolete use: Common.Globals.HostSettings
Seems a little circular.

Where can I find clarification?
Thanx

Thanx

L Douglas
 
New Post
3/9/2011 7:36 PM
 
In the later versions of DotNetNuke 5.x, the class DotNetNuke.Entities.Host.Host exposes most (if not all) of the host settings as strongly typed shared (static) read-only properties. For example:

Dim hostSpace As Double = DotNetNuke.Entities.Host.Host.HostSpace

In order to access the host settings dictionary via the HostController class you must first create an instance of the HostController class, for example:

Dim hostSettings As Dictionary(of String, String) = DotNetNuke.Entities.Host.HostController.Instance.GetSettingsDictionary()
Dim hostSpace As Double = Double.Parse(hostSettings("HostSpace"))   'note - add error handling for parse exception or use TryParse

The HostController class also exposes a number of shared methods to return strongly typed value for a single settings key, for example:

Dim hostSpace As Double = DotNetNuke.Entities.Host.HostController.Instance.GetDouble("HostSpace", 0.0#)

Note that the last parameter is the default value to be used should the setting be missing from the dictionary.

In general, you should access the highest level API which meets your needs to reduce the change of later versions breaking your code. This would suggest that accessing host settings via the shared read-only properties of the Host class is generally the best approach.

Regarding your comment on the conflicting information on deprecated/obsolete methods - I agree they can be confusing and sometimes circular or in some cases such as the one for Host.GetHostSettingsDictionary saying that it is replaced by HostController.,GetHostSettings Dictionary() - which does not exist. Should have been HostController.GetSettingsDictionary().

Much of the code that I write makes heavy use of core API's such as this - although I do not recommend developing within a source package install of DotNetNuke, I find it helpful to do a separate install of the source package for the version my extension will target and keeping its solution open in a separate instance of Visual Studio so I can quickly look at the source code to answer questions such as yours.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesConfused about GetHostSettingsConfused about GetHostSettings


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out