繁体   English   中英

在我的C#项目中启动时未处理的异常

[英]unhandled exceptions at startup in my c# project

在输出窗口中启动我的chatbot应用程序时,我遇到未处理的异常。

Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.dll
Exception thrown: 'System.Globalization.CultureNotFoundException' in mscorlib.dll
Exception thrown: 'System.Security.SecurityException' in mscorlib.dll
Exception thrown: 'System.BadImageFormatException' in mscorlib.dll
Exception thrown: 'System.ArgumentNullException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

我的MessageController中有东西

public class MessagesController : ApiController
    {
        private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
        private static DocumentClient client;
        // Retrieve the desired database id (name) from the configuration file
        private static readonly string databaseId = ConfigurationManager.AppSettings["DatabaseId"];
        // Retrieve the desired collection id (name) from the configuration file
        private static readonly string collectionId = ConfigurationManager.AppSettings["CollectionId"];
        // Retrieve the DocumentDB URI from the configuration file
        private static readonly string endpointUrl = ConfigurationManager.AppSettings["EndpointUri"];
        // Retrieve the DocumentDB Authorization Key from the configuration file
        private static readonly string authorizationKey = ConfigurationManager.AppSettings["PrimaryKey"];

        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            Trace.TraceInformation($"Type={activity.Type} Text={activity.Text}");

            //disable the Application Insights and DocumentDb logging in local enviornment
            #if (LOCAL)            
                Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.DisableTelemetry = true;
            #endif
            #if (!LOCAL)
                if (!String.IsNullOrEmpty(endpointUrl) &&  !String.IsNullOrEmpty(authorizationKey))
                { 
                    using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
                    {
                        await CaptureConversationData(activity);
                    }
                }
            #endif

            if (activity.Type == ActivityTypes.Message)
            {
                //await Microsoft.Bot.Builder.Dialogs.Conversation.SendAsync(activity, () => new ContactOneDialog());

                //Implementation of typing indication
                //ConnectorClient connector = new ConnectorClient(new System.Uri(activity.ServiceUrl));
                //Activity isTypingReply = activity.CreateReply("Shuttlebot is typing...");
                //isTypingReply.Type = ActivityTypes.Typing;
                //await connector.Conversations.ReplyToActivityAsync(isTypingReply);

                logger.Debug("The User's local timeStamp is: " + activity.LocalTimestamp + "and service timeStamp is: " + activity.Timestamp);
                await Conversation.SendAsync(activity, () =>
                new ExceptionHandlerDialog<object>(new ShuttleBusDialog(), displayException: true));
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(System.Net.HttpStatusCode.OK);
            return response;
        }
}

它扔在第一行

private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

这是快照 Exceptione exception2

一件奇怪的事情是,如果我的项目从C:\\ Users \\\\ chatbot \\ Mybot ..运行,那么即使我将break例外设置放在例外设置窗口中,也不会抛出这些例外。 但是,如果我将项目移至c:\\ Sandy \\ MyStuff \\ ChatbOt \\ MyBot,则会开始抛出所有这些异常,因为我已将break异常设置放在了异常设置窗口中。

我严重无法理解问题所在。

尝试以管理员身份运行Visual Studio或以管理员身份运行应用程序,并检查新路径中是否存在项目所依赖的所有Dll。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM