Search code examples
asp.netvisual-studiobotframework

How to see all references/calls to keys in app.config or web.config in a visual studio solution?


The question: Using Visual Studio, it's possible to see all references to classes/methods, etc. Is there a way to do the same for app.config/web.config keys?

The situation/details: I have 3 keys in a web.config as part of a botframework solution: MicrosoftAppId, MicrosoftAppPassword, and DataStore.

Searching for "ConfigurationManager.AppSettings", I only get one result: a reference to the DataStore key, which I added myself. I cannot find any references to the other keys. I've also searched the entire solution for the names of both keys, and I get no results. The bot framework docs indicate the purpose of these keys (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0) and the bot doesn't work if I comment them out, so I know they are being called somewhere, but I need help finding where.

The reason I am trying to find where these keys are called in the code is: I need to move these keys/values to a different, encrypted file, and will need to know where the code needs to be redirected to the new location.

Thanks in advance!


Solution

  • For the first question, "Using Visual Studio, it's possible to see all references to classes/methods, etc. Is there a way to do the same for app.config/web.config keys?" -- I've found that the answer is no.

    Regarding how to see where the bot framework is calling the appid and password, apparently that's done in the bot framework sdk.

    Regarding how to point the code to load appid and password from elsewhere, here is a good example of how to implement a custom credential provider and a custom constructor for the Messages Controller: https://github.com/Microsoft/botbuilder-dotnet/issues/689. This resolved the issue.