Enterprise Bot Template Exception with Web Chat - botframework

Created a new project for the Enterprise template, works fine in emulator (development and production), but in Web Chat, after waking it up with "hi", get the welcome card and "What is your name?" then "Sorry, it looks like something went wrong.". I have found this is due to a MissingMemberException exception at the first line of OnboardingDialog.AskForEmail where it retrieves the state:
_state = await _accessor.GetAsync(sc.Context);
One odd thing is that the AskForName method is called before this and successfully gets the (empty) state, but then doesn't actually wait for a response.
Any ideas?
Stack trace:
System.MissingMemberException: Property not set and no default provided.
at Microsoft.Bot.Builder.BotState.BotStatePropertyAccessor`1.d__7.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at EnterpriseBot.OnboardingDialog.d__8.MoveNext() in C:\dev\EnterpriseBot\EnterpriseBot\Dialogs\Onboarding\OnboardingDialog.cs:line 62
...
Thanks for any help,
David

Related

Is there a AAD login web test that I can use for the Azure availability test as the one I am using is randomly generating context parameter errors?

We are running a web test that uses AAD to login to a web site. When run via Visual Studio the web test runs correctly. However, when run in Azure availability this generates missing context parameter errors. I have attached the error call stack. This is causing availability dips. The error is not specific to a Azure region. I need a web test that works.
There is no try catch mechanism in web tests so I cannot filter out such errors.
I can't upload or paste the web test but its a Azure AAD login web test.
I expect the web test to work. However, I get the following errors:
2 primary requests, 0 dependant requests and 0 conditional rules failed
Exception (subtype 'WebTestException') occured at (UTC) for Uri 'https://login.microsoftonline.com/kmsi', step #5 with the error 'Context parameter 'FormPostParam1.ctx' not found in test context', exception text 'Microsoft.VisualStudio.TestTools.WebTesting.WebTestException: Context parameter 'FormPostParam1.ctx' not found in test context at
Microsoft.VisualStudio.TestTools.WebStress.HelperMethods.UpdateBindingSites(WebTestCaseContext testCaseContext, String preBoundString) at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.PerformRequestDataBinding() at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.Execute(WebTestCaseContext testCaseContext, AsyncCallback completionCallback, Object callerState)', stack trace ' at
Microsoft.VisualStudio.TestTools.WebStress.HelperMethods.UpdateBindingSites(WebTestCaseContext testCaseContext, String preBoundString) at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.PerformRequestDataBinding() at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.Execute(WebTestCaseContext testCaseContext, AsyncCallback completionCallback, Object callerState)'.
Exception (subtype 'WebTestException') occured at (UTC) for Uri '', step #6 with the error 'Context parameter '$HIDDEN1.code' not found in test context', exception text 'Microsoft.VisualStudio.TestTools.WebTesting.WebTestException: Context parameter '$HIDDEN1.code' not found in test context at
Microsoft.VisualStudio.TestTools.WebStress.HelperMethods.UpdateBindingSites(WebTestCaseContext testCaseContext, String preBoundString) at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.PerformRequestDataBinding() at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.Execute(WebTestCaseContext testCaseContext, AsyncCallback completionCallback, Object callerState)', stack trace ' at
Microsoft.VisualStudio.TestTools.WebStress.HelperMethods.UpdateBindingSites(WebTestCaseContext testCaseContext, String preBoundString) at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.PerformRequestDataBinding() at
Microsoft.VisualStudio.TestTools.WebStress.WebTestInstrumentedTransaction.Execute(WebTestCaseContext testCaseContext, AsyncCallback completionCallback, Object callerState)'.

HttpListenerContext.AcceptWebSocketAsync error 1229

I'm trying to add a WebSocket to existing code which handles HTTP requests. Not using IIS or ASP.NET, just C# code with an HttpListener. When the client sends the upgrade request, the server bombs:
System.Net.WebSockets.WebSocketException was unhandled by user code
ErrorCode=1229
HResult=-2147467259
Message=An error occurred when sending the WebSocket HTTP upgrade response during the AcceptWebSocketAsync operation. The HRESULT returned is '1229'
NativeErrorCode=1229
Source=System
StackTrace:
at System.Net.WebSockets.WebSocketHelpers.<AcceptWebSocketAsyncCore>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at mycode.<mymethod>d__46.MoveNext()
InnerException:
Calling code:
HttpListenerContext context = listener.GetContext();
if (context.Request.IsWebSocketRequest)
{
HttpListenerWebSocketContext wsContext = await context.AcceptWebSocketAsync(null);
I find the MS documentation on the entire WebSockets namespace to be useless with no code examples. I don't know what it's trying to tell me here (other than the obvious fact that I'm not handling the exception - I want to know why there is an exception in the first place).
This is Windows 10, .NET framework 4.5. I have noticed places in the documentation which say that WebSockets only works with Windows 8 and 2012, but I assume it should work with 10 too.
Had to go to Windows Features, under IIS (even though I'm not using IIS), and turn on WebSocket Protocol. I don't know whether this being off is Win10 default or just due to the image IT installed for me.

Bot Framework Test connection to your bot fails with status code Forbidden

My bot works receives and sends messages fine in Slack, Skype and emulator.
However when I click the blue Test button in the bot portal (https://dev.botframework.com/) it gives me the error message "Authorization for Microsoft App ID my_id_is_replacedhere failed with status code Forbidden"
Full error is below.
I also get the same error when I send a scheduled message to Slack using endpoint https://slack.botframework.com/ and the Conversations.SendToConversation() method. This used to work and the Test button used to succeed.
Why am I getting this message? Is there a NuGet pkg update that broke it?
I went through the troubleshooting guide, but everything else seem to work.
Thank you
InternalServerError { "message": "An error has occurred.",
"exceptionMessage": "Authorization for Microsoft App ID
my_id_is_replacedhere failed with status code Forbidden",
"exceptionType": "System.UnauthorizedAccessException", "stackTrace": "
at
Microsoft.Bot.Connector.JwtTokenRefresher.d__2.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n
at
Microsoft.Bot.Connector.Conversations.d__8.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
Microsoft.Bot.Connector.ConversationsExtensions.d__19.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at
Grasp.MessagesController.d__0.MoveNext() in
C:\Code\Relegraph_Git\GraspThree\Grasp\Controllers\MessagesController.cs:line
55\r\n--- End of stack trace from previous location where exception
was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Threading.Tasks.TaskHelpersExtensions.d__3`1.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
}
Try use
MicrosoftAppCredentials.TrustServiceUrl(notify.ServiceUrl, DateTime.MaxValue);
before
connector.Conversations.SendToConversationAsync(...)
I figured out what caused the error. Apparently the Test button in the bot portal sends a "Ping" message to the bot. In my MessagesController code I was trying to reply to every message with something like this:
ConnectorClient connector = new ConnectorClient(new Uri(Act.ServiceUrl), appcred);
Activity reply = Act.CreateReply(replymsg);
connector.Conversations.ReplyToActivity(reply);
However - when I do this for the Ping type of Activity (Activity.Type=ActivityTypes.Ping), then I get the above error. When I just ignore the Ping message, then the Test button works.
I still had an issue when I get the same error when sending messages to Slack on a schedule (no incoming message to reply to). I worked around that issue using Slack's WebAPI:
https://slack.com/api/chat.postMessage?token={0}&channel={1}&text={2}&as_user={3}

How to catch OleObject exception in Inno Setup?

So I try to make a post request having no internet connection using next modified code:
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
WinHttpReq.Open('POST', '<your_web_server>', false);
WinHttpReq.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
try
WinHttpReq.Send('data');
except
bla:= 'e';
finally
bla := 'f';
end;
Yet exception does not get catched and I get crush of my setup application with next image:
How to handle OleObject exception in Inno Setup?
Your code is incomplete, but try..except block catches all the exceptions, including those thrown by OLE objects. However, your screenshot shows the line number, where the exception was thrown, and so you were running debugger.
And debugger shows all exception messages regardless they are in a try..except block, unless you uncheck "Pause on exceptions" option in Inno Setup IDE settings:
By default is this option enabled (which I would recommend to keep), which means that all exceptions are reported as exception messages and that's what might have mislead you. If you were running your setup without debugger attached, you wouldn't see that exception message.

advertising Ad control disappear and Throws Exception in windows phone 7

i am getting exception from Adcontrol as
"A first chance exception of type 'Microsoft.Advertising.Mobile.Shared.AdException' occurred in Microsoft.Advertising.Mobile.dll".
my ad control is disappear and throw this kind of exception so what should i do for this kind of problem please Tell me if anybody known
The exception is probably thrown because there isn't any ad served.
Your app will only receive ads if they are available. If it is not the case, the control disappears. You get that exception while you are debugging the app, but when deployed and executed in a real device, it doesn't make the app break.
Anyway, just to make sure that this is what causes the exception you can subscribe to the ErrorOccurred event of the ad control, and check what happens:
private void AdControl_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Ad Error : ({0}) {1}", e.ErrorCode, e.Error);
}

Resources