【发布时间】:2015-07-15 05:40:53
【问题描述】:
我的应用程序运行良好,Visual Studio 中的错误让我发疯。实际错误是:
找不到路径“C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\emailTemplates”的一部分。
我的程序启动,并用与应用程序相关的目录中的所有 .msg 文件填充组合框。就像我说的,它编译并运行良好。我尝试过重建、清洁等,但没有任何效果。清洁似乎可以解决它,直到我再次构建它。怎么回事??
主窗口:
<Window x:Class="abfsEmailGenerator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:custom ="clr-namespace:abfsEmailGenerator"
Title="MainWindow" Height="700" Width="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander x:Name="emailSelectExpander" Header="Select Email" HorizontalAlignment="Right" Width="592">
<custom:HtmlViewer></custom:HtmlViewer>
</Expander>
</Grid>
</Window>
HTML查看器:
<UserControl x:Class="abfsEmailGenerator.HtmlViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="28*"/>
<ColumnDefinition Width="243*"/>
</Grid.ColumnDefinitions>
<Label Margin="3" Grid.Row="0">CC:</Label>
<TextBox x:Name="ccText" Margin="3" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" />
<Label Margin="3" Grid.Row="1">Subject:</Label>
<TextBox x:Name="subjectText" Margin="3" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
<WebBrowser Margin="3,3,3,33" x:Name="bodyBrowser" Grid.Row="2" Grid.ColumnSpan="3" VerticalAlignment="Stretch" Height="500" Grid.RowSpan="2"></WebBrowser>
<ComboBox x:Name="emailSelector" Grid.Row="3" Grid.Column="0" Margin="3" Grid.ColumnSpan="3" DropDownClosed="emailSelector_DropDownClosed"/>
</Grid>
HtmlViewer 代码:
namespace abfsEmailGenerator
{
/// <summary>
/// Interaction logic for HtmlViewer.xaml
/// </summary>
public partial class HtmlViewer : UserControl
{
outlook.Application oApp = new outlook.Application();
private Dictionary<string, Dictionary<string, dynamic>> emailDict = new Dictionary<string, Dictionary<string, dynamic>>();
public HtmlViewer()
{
InitializeComponent();
populateCb();
}
private void populateCb()
{
string emailFolder = AppDomain.CurrentDomain.BaseDirectory + "/emailTemplates";
emailDict.Clear();
emailSelector.ItemsSource = null;
foreach (var file in Directory.EnumerateFiles(emailFolder, "*.msg", SearchOption.AllDirectories))
{
...
}
}
}
【问题讨论】:
-
您是否完全退出了visual studio,问题又出现了?我一直收到“幻影”错误,直到所有 Visual Studio 实例都关闭后才会消失......
-
是的,我试过了。它通常有效,但这次不行。
标签: c# wpf xaml visual-studio-2013 custom-controls