Jira .NET SDK: issue.Savechange() throw unknown exception - c#

The .NET program I used to create Jira issues automatically failed to save the new created issue recently. The tool was working perfectly until a few days ago, so I guess the problem might be on the Jira server side. See the attached pics for exception details. What causes this exception? thanks.
The problem is resolved after removing following code, weird.
//new_issue.Priority = "None";
I tried following ways to set priority, but they both triggers that exception?
var new_issue = jira.CreateIssue("THINPRO");
new_issue.Components.Add("Security");
new_issue.Type = "Bug";
new_issue.Summary = "test;
new_issue.Description = "test;
/ set priority based on CVSS score use priority id
//1 = Highest 2 = High 3 = Medium 4 = Low 5 = Lowest 6 = (not used) 7 = None
if (score <= 0.0)
new_issue.Priority = "7";
else if (score >= 7.0)
new_issue.Priority = "2" ;
else if (score <= 4.0)
new_issue.Priority = "4";
else
new_issue.Priority = "3";
new_issue.SaveChanges();
// set priority based on CVSS score use priority name
if (score <= 0.0)
new_issue.Priority = "None";
else if (score >= 7.0)
new_issue.Priority = "High";
else if (score <= 4.0)
new_issue.Priority = "Low";
else
new_issue.Priority = "Medium";
new_issue.SaveChanges();
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: Response Content:
at Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest request, IRestResponse response)
at Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__11.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 Atlassian.Jira.Remote.JiraRestClient.<ExecuteRequestAsync>d__10`1.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 Atlassian.Jira.Remote.IssuePriorityService.<GetPrioritiesAsync>d__2.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 Atlassian.Jira.IssuePriority.<GetEntitiesAsync>d__2.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 Atlassian.Jira.JiraNamedEntity.<LoadIdAndNameAsync>d__12.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.ValidateEnd(Task task)
at Atlassian.Jira.Issue.<ToRemoteAsync>d__158.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 Atlassian.Jira.Issue.SaveChanges()

The value None is probably an invalid value.
In most (and default) Jira configuration, you cannot empty the Priority field. It's the system field and it must have a value from predefined list (usually something like Blocker, Critical, Major, Minor, Trivial).

Related

c# azure devops repo builder has stopped working suddenly

So I wrote a little c# utility which connects to my devops azure repo and downloads a bunch of files in a zip, then unpacks the zip file(s) and then does a text search and replace to customise the files.
This utility was working fine up to Friday 8th. On Monday 11th the utility started telling me i was unauthorised.
This utility is used by 3 other colleagues and it is still working a-ok for them, just not me :(
The utility has been working fine for over 4 months until his week.
Here's the pertinent code:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.WebApi;
using System.IO;
using System.IO.Compression;
namespace ########.######.####.#######
{
class Program
{
const String c_collectionUri = "https://dev.azure.com/#################";
const String c_projectName = "########.######.#######.######.#########";
const String c_variableGroupId = "########-####-####-####-############"; // id for the LIVE project / repos
const String download_dir = #"C:\###########\";
const String dev_short_name_txt = "$$dev_shortname$$";
const String dev_long_name_txt = "$$dev_long_name$$";
const String todays_date_txt = "$$todays_date$$";
static System.Collections.Specialized.StringCollection log = new System.Collections.Specialized.StringCollection();
private static string dev_short_name;
private static string dev_long_name;
private static string todays_date;
static void Main(string[] args)
{
// gets just the username, e.g. ############
dev_short_name = Environment.UserName;
Console.WriteLine("Who are you : " + dev_short_name);
DateTime today = DateTime.Today; // As DateTime
todays_date = today.ToString("dd/MM/yyyy"); // As String
Console.WriteLine("Today is : " + todays_date);
// Interactively ask the user for credentials, caching them so the user isn't constantly prompted
VssCredentials creds = new VssClientCredentials();
creds.Storage = new VssClientCredentialStorage();
// Connect to Azure DevOps Services
VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);
Console.WriteLine("");
Console.WriteLine("Projects....");
Console.WriteLine("");
ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();
TeamHttpClient teamClient = connection.GetClient<TeamHttpClient>();
// Call to get the list of projects
IEnumerable<TeamProjectReference> projects = projectClient.GetProjects().Result;
Dictionary<TeamProjectReference, IEnumerable<WebApiTeam>> results = new Dictionary<TeamProjectReference, IEnumerable<WebApiTeam>>();
// Iterate over the returned projects
foreach (var project in projects)
{
// Get the teams for the project
IEnumerable<WebApiTeam> teams = teamClient.GetTeamsAsync(project.Name).Result;
// Add the project/teams item to the results dictionary
results.Add(project, teams);
Console.WriteLine(" " + project.Id + " " + project.Name);
Here's the error output:
Who are you : ###############
Today is : 14/07/2022
Projects....
Unhandled Exception: Microsoft.VisualStudio.Services.WebApi.VssServiceResponseException: Unauthorized
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__53.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 Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__51.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 Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__47`1.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 Microsoft.VisualStudio.Services.Location.Client.LocationHttpClient.<GetConnectionDataAsync>d__6.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<GetConnectionDataAsync>d__56.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<ConnectAsync>d__41.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<EnsureConnectedAsync>d__39.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<CheckForServerUpdatesAsync>d__38.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<FindServiceDefinitionAsync>d__35.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 Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.<LocationForCurrentConnectionAsync>d__29.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 Microsoft.VisualStudio.Services.WebApi.Location.LocationService.<ResolveLocationDataAsync>d__3.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 Microsoft.VisualStudio.Services.WebApi.Location.LocationService.<GetLocationDataAsync>d__2.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 Microsoft.VisualStudio.Services.WebApi.VssConnection.<GetClientInstanceAsync>d__20.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 Microsoft.VisualStudio.Services.WebApi.VssConnection.<GetClientServiceImplAsync>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 Microsoft.VisualStudio.Services.WebApi.VssConnection.<GetClientAsync>d__14`1.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 Microsoft.VisualStudio.Services.WebApi.TaskExtensions.SyncResult[T](Task`1 task)
at Microsoft.VisualStudio.Services.WebApi.VssConnection.GetClient[T]()
at ########.######.####.#######.Program.Main(String[] args) in C:\########\########.######.####.#######\########.######.####.#######\Program.cs:line 60
I've googled around and tried various things like:
deleting C:\Users\###########\AppData\Local.IdentityService
clearing temp internet files / folders from both Edge and Chrome
removing all generic credetials from the Credential Manager
using alternatives to VssCredentials / VssClientCredentialStorage / VssConnection like:
// Interactively ask the user for credentials, caching them so the user isn't constantly prompted
VssCredentials creds = new VssClientCredentials();
creds.Storage = new VssClientCredentialStorage();
Console.WriteLine("creds : " + creds.Windows.ToString());
Console.WriteLine("creds2 : " + creds.Storage.ToString());
// Connect to Azure DevOps Services
VssConnection connection;
ProjectHttpClient projectClient;
try
{
connection = new VssConnection(new Uri(c_collectionUri), creds);
projectClient = connection.GetClient<ProjectHttpClient>();
}
catch (VssServiceResponseException e)
{
Console.WriteLine(e);
connection = new VssConnection(new Uri(c_collectionUri), new VssAadCredential());
//connection = new VssConnection(new Uri(c_collectionUri), new VssBasicCredential(string.Empty, personalAccessToken));
//connection = new VssConnection(new Uri(c_collectionUri), new VssBasicCredential("##############","###################################"));
projectClient = connection.GetClient<ProjectHttpClient>();
}
//VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);
//VssConnection connection = new VssConnection(new Uri(c_collectionUri), new VssAadCredential());
But I still can't get in!!!
I'm not aware of any changes being made to my device.
Our IT guys fixed this one. I was missing a trusted site setting, which they've added via a browser GPO for edge / chrome.
:)

Execution Timeout Expired after inserting into database and then using EF Core to update database with completion

Note: This runs without any issues on my local computer, but when I push it up to our Azure instance I see the TimeoutExpired
I'm running into a weird issue where we are inserting records into the database. The file I'm working on has 103k inserts. The actual inserts to the database are completed successfully. When it goes to update my database table via EF Core that the import has been successful I see this error:
Error: Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__180_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- 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.ValidateEnd(Task task)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>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 Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.<ExecuteAsync>d__10.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 Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__7`2.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 Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__81.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 Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__79.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 Microsoft.EntityFrameworkCore.DbContext.<SaveChangesAsync>d__53.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 PTI.BI.API.ExcelImporter.DAL.Repositories.BaseRepository.<SaveChangesAsync>d__13.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 PTI.BI.API.ExcelImporter.DAL.Repositories.ImportRepository.<UpdateImportGenerateScript>d__7.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 PTI.BI.API.ExcelImporter.BLL.Service.ImportService.<UpdateImportGenerateScript>d__31.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.ValidateEnd(Task task)
at PTI.BI.API.ExcelImporter.BLL.Service.ImportService.<ProcessImport>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
Here is the code that is doing the updates to my database, one at a time (for error checking). This code is working fine.
using (var sqlConnection = new SqlConnection(connectionString))
{
try
{
sqlConnection.Open();
sqlTransaction = sqlConnection.BeginTransaction();
// #### Pre populate items (generate delete statement)
trackingInfo.FileDetail = UpdateImportMetricStatus(trackingInfo.FileDetail, ImportMetricStatus.PrepopulateScript);
trackingInfo = await PrepopulateApplyScript(trackingInfo).ConfigureAwait(false);
if (trackingInfo.IsSuccessful == false)
{
return trackingInfo;
}
// apply the delete records sql script if found.
if (string.IsNullOrWhiteSpace(trackingInfo.DeleteRecordsSqlScript.ToString()) == false)
{
trackingInfo.FileDetail = UpdateImportMetricStatus(trackingInfo.FileDetail, ImportMetricStatus.GenerateDeleteSqlScript);
errorSqlScript = trackingInfo.DeleteRecordsSqlScript.ToString();
using (var cmd = new SqlCommand(trackingInfo.DeleteRecordsSqlScript.ToString(), sqlConnection, sqlTransaction))
{
cmd.CommandType = CommandType.Text;
await cmd.ExecuteScalarAsync().ConfigureAwait(false);
}
// append delete statement to the main SQL script
trackingInfo.SqlScript.AppendLine(trackingInfo.DeleteRecordsSqlScript.ToString());
}
// #### Create table script IF we are creating a new table
if (trackingInfo.FileDetail.DestinationDetail.CreateNewTable == true && trackingInfo.FileDetail.DestinationDetail.UseExistingTable == false)
{
trackingInfo = await CreateTableScript(trackingInfo).ConfigureAwait(false);
if (trackingInfo.IsSuccessful == false)
{
return trackingInfo;
}
// apply the create table sql script if found.
if (string.IsNullOrWhiteSpace(trackingInfo.CreateTableSqlScript.ToString()) == false)
{
trackingInfo.FileDetail = UpdateImportMetricStatus(trackingInfo.FileDetail, ImportMetricStatus.GenerateCreateTableScript);
errorSqlScript = trackingInfo.CreateTableSqlScript.ToString();
using (var cmd = new SqlCommand(trackingInfo.CreateTableSqlScript.ToString(), sqlConnection, sqlTransaction))
{
cmd.CommandType = CommandType.Text;
await cmd.ExecuteScalarAsync().ConfigureAwait(false);
}
// append delete statement to the main SQL script
trackingInfo.SqlScript.AppendLine(trackingInfo.CreateTableSqlScript.ToString());
}
}
// ### Insert table scripts
trackingInfo.FileDetail = UpdateImportMetricStatus(trackingInfo.FileDetail, ImportMetricStatus.GenerateInsertScripts);
trackingInfo = await GenerateInsertTableScript(trackingInfo).ConfigureAwait(false);
// apply the create table sql script if found.
if (string.IsNullOrWhiteSpace(trackingInfo.InsertSqlScript.ToString()) == false)
{
trackingInfo.FileDetail = UpdateImportMetricStatus(trackingInfo.FileDetail, ImportMetricStatus.PopulatingInsertScripts);
foreach (var item in trackingInfo.InsertSqlScript)
{
errorSqlScript = item;
using (var cmd = new SqlCommand(item, sqlConnection, sqlTransaction))
{
cmd.CommandType = CommandType.Text;
await cmd.ExecuteScalarAsync().ConfigureAwait(false);
}
currentRowLine++;
// append insert statements to the main script...
trackingInfo.SqlScript.AppendLine(item).AppendLine();
}
}
if (trackingInfo.IsSuccessful == false)
{
return trackingInfo;
}
if (trackingInfo.IsSuccessful == true)
{
sqlTransaction.Commit();
return trackingInfo;
}
else
{
return trackingInfo;
}
}
catch (Exception ex)
{
sqlTransaction.Rollback();
trackingInfo.IsSuccessful = false;
trackingInfo.ImportMetricUpdateError = new ImportMetricUpdateErrorDTO(trackingInfo.ImportMetricId)
{
ErrorLineNbr = currentRowLine + 1, // add one to match up with the excel file
ErrorMessage = string.Format(CultureInfo.CurrentCulture, "{0}", ex.Message),
ErrorSQL = errorSqlScript,
RowsProcessed = currentRowLine
};
await LogImporterError(trackingInfo.FileDetail, ex.ToString()).ConfigureAwait(false);
return trackingInfo;
}
}
Again, the delete, create, insert statements all work and update my SQL database without any issues.
Then here is where my code fails:
public async Task UpdateImportMetric(ImportMetricUpdateDTO importMetricUpdate)
{
if (importMetricUpdate == null)
{
throw new ArgumentNullException(nameof(importMetricUpdate));
}
var importMetricDbRecord = await ImportContext.ImportMetrics
.Where(x => x.ImportMetricId == importMetricUpdate.ImportMetricId)
.FirstOrDefaultAsync().ConfigureAwait(false);
if (importMetricDbRecord == null)
{
throw new RecordNotFoundException("No import metric with id: " + importMetricUpdate.ImportMetricId + " could be found.");
}
importMetricDbRecord.ImportStatus = importMetricUpdate.ImportStatus;
importMetricDbRecord.ImportStatusHistoriesJson = string.IsNullOrWhiteSpace(importMetricUpdate.ImportStatusHistoriesJson) == true ? importMetricDbRecord.ImportStatusHistoriesJson : importMetricUpdate.ImportStatusHistoriesJson;
importMetricDbRecord.Ended = importMetricUpdate.Ended;
importMetricDbRecord.Duration = importMetricUpdate.Duration;
importMetricDbRecord.RowsProcessed = importMetricUpdate.RowsProcessed;
importMetricDbRecord.IsSuccessful = importMetricUpdate.IsSuccessful;
importMetricDbRecord.ErrorLineNbr = importMetricUpdate.ErrorLineNbr;
importMetricDbRecord.ErrorMessage = importMetricUpdate.ErrorMessage;
importMetricDbRecord.ErrorSQL = importMetricUpdate.ErrorSQL;
importMetricDbRecord.ModifiedBy = ImportContext.UserRequestingId;
importMetricDbRecord.ModifiedDate = DateTime.UtcNow;
await SaveChangesAsync().ConfigureAwait(false);
}
As you can see the issue appears to be on my SaveChangesAsync().
So I think it is something with EF Core instead of the code to actually insert the statements into the db since that appears to be working.
Also, after starting the Import from the user clicking a button on the MVC page, I am kicking off the Import in Async mode, so the UI responds back and a loading panel will run for the user.
Here is that code:
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Task.Run(async ()=> await ProcessImport(submitImportItemsAndProcessImport.ImportDetailId, importMetricId, currentUserId));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
I'm in a using() on the connection so that should be closed out.
It is almost like something is being left open and therefore EF Core can't continue with the updates after moving away from using SQLCommand.
Any ideas?
Answer:
It appears the script is so large that StringBuilder.ToString(); was causing an Out of Memory exception and thus causing the timeout.
Since the script is so large. We are planning to go to FileStream instead of StringBuilder.

how to send images which are in local folder in microsoft botframework sdk v4 using c#

I created a bot with Microsoft Botframework C# SDK V4 and it is working well. Now I want to add some images to that bot. I am using cards but cards are taking only url of an image. I want to send the images which are in my local folder. How can I make it work??
I already tried this with 15.handling attachments github repo(https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/15.handling-attachments). And while I am using the exact code in handling attachments github repo, I am getting the below exception stacktrace for inline attachments.
Sorry, it looks like something went wrong.’ at Microsoft.Bot.Connector.Conversations.d__10.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.d__17.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.BotFrameworkAdapter.d__15.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.TurnContext.<>c__DisplayClass22_0.
<g__SendActivitiesThroughAdapter|1>d.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.TurnContext.d__21.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.BotBuilderSamples.AttachmentsBot.d__0.MoveNext() in
C:\botbuilder-samples\samples\csharp_dotnetcore\15.handling-attachments\AttachmentsBot.cs:line 65
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.MiddlewareSet.d__3.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.BotAdapter.d__13.MoveNext()’
How can I resolve this issue??
The 15.handling-attachments sample demonstrates how to read a local file, and attach it as a base64 encoded image:
reply.Attachments = new List<Attachment>() { GetInlineAttachment() };
private static Attachment GetInlineAttachment()
{
var imagePath = Path.Combine(Environment.CurrentDirectory, #"Resources\architecture-resize.png");
var imageData = Convert.ToBase64String(File.ReadAllBytes(imagePath));
return new Attachment
{
Name = #"Resources\architecture-resize.png",
ContentType = "image/png",
ContentUrl = $"data:image/png;base64,{imageData}",
};
}
Another option is to use the ConnectorClient's UploadAttachmentAsync api:
private async Task SendFile(ITurnContext turnContext)
{
var webRoot = _env.ContentRootPath;
var imagePath = System.IO.Path.Combine(webRoot, "Resources", "BotFrameworkDiagram.png");
var connector = turnContext.TurnState.GetValueOrDefault("Microsoft.Bot.Connector.IConnectorClient") as ConnectorClient;
var attachments = new Attachments(connector);
var response = await attachments.Client.Conversations.UploadAttachmentAsync(
turnContext.Activity.Conversation.Id,
new AttachmentData
{
Name = "BotFrameworkDiagram.png",
OriginalBase64 = File.ReadAllBytes(imagePath),
Type = "image/png"
});
var attachmentUri = attachments.GetAttachmentUri(response.Id);
var attachment = new Attachment
{
Name = "BotFrameworkDiagram.png",
ContentType = "image/png",
ContentUrl = attachmentUri
};
var reply = turnContext.Activity.CreateReply();
reply.Attachments.Add(attachment);
await turnContext.SendActivityAsync(reply);
}

Splitting a string throws InvalidOperationException when hosting on IIS

I wrote the following code:
private string makeMailContents(Klant klant, Mail mail)
{
var builder = new BodyBuilder();
var path = Path.Combine("wwwroot/trackers/track_open.png");
var img = builder.LinkedResources.Add(path);
byte[] data = Convert.FromBase64String(mail.Content);
string decoded = Encoding.UTF8.GetString(data);
string code;
string final = "";
Regex regex = new Regex(#"\[([^]]*)\]");
img.ContentId = MimeUtils.GenerateMessageId();
var splitContent = decoded.Split(' ');
foreach(string word in splitContent) // this is line 265
{
if (word.Contains('[') && word.Contains(']'))
{
try
{
code = Regex.Match(word, #"\[([^]]*)\]").Groups[1].Value.ToLower();
switch (code)
{
case "voornaam":
final += regex.Replace(word, klant.vnaam) + ' ';
break;
case "achternaam":
final += regex.Replace(word, klant.anaam) + ' ';
break;
case "naam":
final += regex.Replace(word, klant.vnaam + ' ' + klant.anaam + ' ');
break;
case "onderwerp":
final += regex.Replace(word, mail.Onderwerp + ' ');
break;
case "datum":
final += regex.Replace(word, DateTime.Now.ToString("dd-MM-yyyy") + ' ');
break;
}
}
catch (Exception ex)
{
final += ex;
}
}
else
{
final += word + ' ';
}
}
}
Whenever I run this code on my local machine and my test server it executes the code like it should without any exceptions.
But whenever I host this on my current live server it throws the following exception:
InvalidOperationException: Sequence contains no elements
And this exceptions keeps pointing towards the splitContent and it tells me that it doesn't contain elements. And yes, the mail.Content is filled with a valid base64 string, I checked both with fiddler and postman.
Does anyone have the slightest clue of what's going on here? I'm also not sure if it's the IIS settings or somehow my code. I normally have a colleague who manages the IIS but he is on vacation right now. Can someone help me out with this?
This is the data the mail receives when called:
{
"Onderwerp":"Dit is een test campagne",
"afzender":1,
"campagne":1,
"Content":"PHA+RGl0IGlzIGVlbiB0ZXN0IG1hYXQ8L3A+Cg==",
"docs":"['kamer2.jpg']",
"template":null,
"verzenddat":"8/17/18, 3:55 PM"
}
full exception:
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
at lambda_method(Closure , QueryContext )
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass17_1`1.<CompileQueryCore>b__0(QueryContext qc)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Last[TSource](IQueryable`1 source)
at MailerAPI.Mailer.Sender.makeMailContents(Klant klant, Mail mail) in C:\Users\Hofkey\Source\Repos\MailerAPI\MailerAPI\Mailer\Sender.cs:line 265
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at MailerAPI.Mailer.Sender.<sendMessage>d__7.MoveNext() in C:\Users\Hofkey\Source\Repos\MailerAPI\MailerAPI\Mailer\Sender.cs:line 161
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MailerAPI.Controllers.MailController.<Post>d__13.MoveNext() in C:\Users\Hofkey\Source\Repos\MailerAPI\MailerAPI\Controllers\MailController.cs:line 96
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
The exception also gets thrown when I replace the model properties with just a plain string.
UPDATE
Whenever I run this code in my values controller to test the decoded.split(' ') it actually works. When I return the decoded.split(' ') I actually get an array of strings.
So now I know that the problem only occurs within the method, which is located in a Sender class and being called in the MailerController, and it also only occurs in the current server.
You appear to be making a call to .Last() at or through the code located at C:\Users\Hofkey\Source\Repos\MailerAPI\MailerAPI\Mailer\Sender.cs:line 265.
The Linq extension method .Last() demands that there is at least one item that it can grab. To work around this requirement, you have various options:
use .LastOrDefault() accompanied with appropriate null handling, or
before using .Last(), first check with if (... .Any()) if it is OK to call .Last().
For further reference, see LINQ Element Operations

PromptDialog not asking in Dialog class

I've been doing a bot with the Microsoft Bot Framework in C# and I encountered a problem.
The problem is that when I call "PromptDialog" to get a String from the user, in this case a password, it doesn't ask for it, it opens the "Password" method and crashes when trying to obtain that String.
Thanks for your help!
The class extends LUISDialog
PromptDialog.Text(context, resume: Password, prompt: "Enter password:");
LUIS Intent null:
[LuisIntent("")]
public async Task None(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
Boolean PassLogin;
Start(context, activity); //Does this need to be awaited?
if (!context.UserData.TryGetValue<Boolean>("PassLogin", out PassLogin)) PassLogin = false;
if (PassLogin)
{
var act = await activity;
if (act.Conversation.IsGroup != null && act.Conversation.IsGroup.Value)
{
context.Wait(MessageReceived);
}
else
{
await Nothing(context, activity, result);
}
}
else context.Wait(MessageReceived);
}
Start Method. The Start method is called by every intent from LUIS.
public async Task Start(IDialogContext context, IAwaitable<IMessageActivity> activity)
{
Boolean PassLogin, start;
if (!context.UserData.TryGetValue<Boolean>("PassLogin", out PassLogin))
{
PassLogin = false;
context.UserData.SetValue<Boolean>("PassLogin", PassLogin);
}
if (!context.UserData.TryGetValue<Boolean>("start", out start))
{
start = true;
}
if (start)
{
PromptDialog.Text(context, resume: Password, prompt: "Enter password:");
await context.PostAsync("Something"); //This prints out before going to password.
}
await GetKey(context, activity);
}
private async Task Password(IDialogContext context, IAwaitable<String> argument)
{
var response = await argument;
if (response=="test")
{
context.UserData.SetValue<Boolean>("PassLogin", true);
await context.PostAsync("Correct Password.");
if (context.UserData.Get<Boolean>("PassLogin"))
{
await context.PostAsync("Welcome");
context.UserData.SetValue<Boolean>("start", false);
}
}
else
{
context.UserData.SetValue<Boolean>("PassLogin", false);
await context.PostAsync("Incorrect password.");
}
context.Wait(MessageReceived); //Does this need to be here? (Tried with and without.)
}
This is what the error says:
Exception: Microsoft.Bot.Builder.Internals.Fibers.InvalidNextException: invalid next: Wait: Poll Object for ThunkStart.Rest have Object at Microsoft.Bot.Builder.Internals.Fibers.Fiber1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Bot.Builder.Internals.Fibers.Wait2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult() at Microsoft.Bot.Builder.Dialogs.Chain.LoopDialog1.<ResumeAsync>d__3.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 Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume1.<Rest>d4.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 Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d19.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 Microsoft.Bot.Builder.Internals.Fibers.Frame1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__7.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 Microsoft.Bot.Builder.Internals.Fibers.Fiber1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d13.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 Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IDialogStack-PollAsync>d19.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 Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d21`1.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 Microsoft.Bot.Builder.Dialogs.Internals.ReactiveDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d31.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 Microsoft.Bot.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__21.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 Microsoft.Bot.Builder.Dialogs.Internals.LocalizedDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d21.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 Microsoft.Bot.Builder.Dialogs.Internals.ScoringDialogTask1.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d31.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 Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__31.MoveNext() — End of stack trace from previous location where exception was thrown — at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d3`1.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 Microsoft.Bot.Builder.Dialogs.Internals.SerializingDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d41.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 Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUserTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__51.MoveNext()
As I wrote in the comments, there are a few issues that would have to be solved:
The call to the Start method must be awaited
There shouldn't be code after the call to PromptDialog.Text. That code is starting a new dialog that will continue in the ResumeAfter method once it's done
All the code after the Start call seems to depend on the ResumeAfter of the Prompt so it should be moved there.

Categories