I am writing a chat bot in Microsoft Bot Framework based on LUIS. (This is my first time using LUIS). I have a basic LuisDialog class where I would like to set the LuisModel attribute. The problem is, defining the LuisModel requires constant values. I would like to retrieve these values from the Web.config file.

This fails, and I get an error message saying "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type". (It is because of retrieving the values from the Web.config file.)

Is there a way to retrieve these values from Web.config file and set them in the attribute?

I tried the following solution but it was not successful:

[LuisModel(Constants.LuisModelId, Constants.LuisSubscriptionKey)]
public class LuisDialog : LuisDialog<object>

internal static class Constants
    internal const string LuisModelId = WebConfigurationManager.AppSettings.Get("LuisModelId");
    internal const string LuisSubscriptionKey = WebConfigurationManager.AppSettings.Get("LuisSubscriptionKey");

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.