简体   繁体   English

Visual Studio 2015设计器崩溃

[英]Visual Studio 2015 designer crash

I have this method: 我有这种方法:

static public void WriteErrorToFile(string ErrorMassege, string HelpLink)
{
    string text = DateTime.Now.ToString() + ":" + Environment.NewLine + ErrorMassege + Environment.NewLine;

    if (!string.IsNullOrWhiteSpace(HelpLink))
    {
        text += "Help link: " + HelpLink + Environment.NewLine;
    }

    text += Environment.NewLine;
    File.AppendAllText("errors.txt", text);
}

I call this method every time some expception occurred, but then the designer in Visual Studio 2015 crashes with massege: 每当发生某种错误时,我都会调用此方法,但随后Visual Studio 2015中的设计器因Massege而崩溃:

UnauthorizedAccessException: Access to the path 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\errors.txt' is denied. UnauthorizedAccessException:拒绝访问路径“ C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ errors.txt”。

If that mean something to you I call this function in MyViewModel what is datacontext of my page. 如果这对您来说意味着什么,我在MyViewModel中调用此函数,这是我页面的datacontext。 If I delete errors.txt file then everything is normal again. 如果我删除errors.txt文件,则一切恢复正常。 Anyone knows why this happen and what is the soulution? 有谁知道为什么会这样,解决方案是什么?

问题是WPF设计人员必须执行代码才能在viewModel上查看可用的数据, DesignerProperties包含GetIsInDesignMode方法,当设计人员执行代码时,可以使用该方法禁用逻辑

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

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