找到多个相同类型的自定义属性。 botframework 中的 c# 异常

Multiple custom attributes of the same type found. c# exception in botframework

我的机器人在 Azure 的一个实例中工作,但是当我试图将它上传到另一个实例时,它停止响应。收到以下异常。

因此,我们被 Bot 框架拒绝了。

    InternalServerError
{
  "message": "An error has occurred.",
  "exceptionMessage": "Multiple custom attributes of the same type found.",
  "exceptionType": "System.Reflection.AmbiguousMatchException",
  "stackTrace": "   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)\r\n   at Microsoft.Rest.ServiceClient`1.get_FrameworkVersion()\r\n   at Microsoft.Rest.ServiceClient`1.SetDefaultUserAgentInfo()\r\n   at Microsoft.Rest.ServiceClient`1.SetUserAgent(String productName, String version)\r\n   at Microsoft.Rest.ServiceClient`1.InitializeHttpClient(HttpClientHandler httpClientHandler, DelegatingHandler[] handlers)\r\n   at Microsoft.Bot.Connector.ConnectorClient..ctor(Uri baseUri, DelegatingHandler[] handlers)\r\n   at Microsoft.Bot.Connector.ConnectorClient..ctor(Uri baseUri, String microsoftAppId, String microsoftAppPassword, DelegatingHandler[] handlers)\r\n   at HoroscopeBot.MessagesController.<Post>d__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.Threading.Tasks.TaskHelpersExtensions.<CastToObject>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.<InvokeActionAsyncCore>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.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>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.<ExecuteAsync>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.<SendAsync>d__1.MoveNext()"
}

截至目前,此问题已发布在 GitHub 上,似乎唯一的解决方案是删除您当前的 azure 实例并创建一个新实例并再次上传您的代码。 这个解决方法对我和其他人也有效。

为了说清楚,

  1. 删除显示错误的当前 Azure 实例。

  2. 创建另一个名称的新实例(使用相同的名称给我带来了问题。它工作了一段时间但后来崩溃了。)

  3. 将您的代码上传到新实例。

这应该像魔术一样起作用。

另请注意,我已删除实例的应用计划。

如有任何疑问,请发表评论。