[.NET Core] AspNetCore 2 app using .NET framework does not initialize MicrosoftAppCredentials
See original GitHub issueI implemented a AspNetCore 2 Bot using .Net 462. I get a notauthorized exception when an intent message is processed by LuisDialog because MicrosoftAppCredentials is not initialized with the credentials.
DialogModule.Load registers MicrosoftAppCredentials without specifying parameters.
builder
.RegisterType<MicrosoftAppCredentials>()
.AsSelf()
.SingleInstance();
When MicrosoftAppCredentials is created this constructor is used with both appId, password set to null :
public MicrosoftAppCredentials(string appId = null, string password = null)
{
MicrosoftAppId = appId;
MicrosoftAppPassword = password;
TokenCacheKey = $"{MicrosoftAppId}-cache";
}
I found a workaround, reregistering MicrosoftAppCredentials :
Conversation.UpdateContainer(
builder =>
{
builder.Register(c => new MicrosoftAppCredentials(microsoftAppId, microsoftAppPassword)).SingleInstance();
});
What is the correct solution for my problem ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
[.NET Core] AspNetCore 2 app using .NET framework does ...
I implemented a AspNetCore 2 Bot using .Net 462. ... MicrosoftAppCredentials is not initialized with the credentials. DialogModule.Load registers ...
Read more >.NET Framework initialization errors: Managing the user ...
This situation typically occurs when an application requires a CLR version that is invalid or not installed on a given computer. If the ......
Read more >Troubleshooting 'This application could not be started'
Error causes. This error typically indicates one of the following conditions: A .NET Framework installation on your system has become corrupted.
Read more >Port from .NET Framework to .NET 6 - .NET Core
Understand the porting process and discover tools you may find helpful when porting a .NET Framework project to .NET 6.
Read more >Migrate from ASP.NET to ASP.NET Core | Microsoft Learn
This article serves as a reference guide for migrating ASP.NET apps to ASP.NET Core. Visual Studio has tooling to help migrate ASP.NET apps...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
With my workaround, reregistering MicrosoftAppCredentials in the AutoFac container, dialogs and forms are working as expected.
Here my Code in Startup.cs. I did not test it in Azure.