c# - WPF Custom Control Design Error -
my application runs fine, error in visual studio driving me crazy. actual error is:
could not find part of path 'c:\program files (x86)\microsoft visual studio 12.0\common7\ide\emailtemplates'.
my program starts up, , populates combo box of .msg files in directory relative application. said, compiles , runs fine. have tried rebuilding, cleaning, etc. nothing works. cleaning seems fix it, until build again. going on??
main window:
<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>
htmlviewer:
<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 code:
namespace abfsemailgenerator { /// <summary> /// interaction logic 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)) { ... } } }
cannot create instance of 'htmlviewer'.
that suggests initialization may culprit.
in design mode don't want control trying work other setting basic , feel of control.
to keep operational activities minimum, may create null instance failures, best segregate code has high possibility of failure such:
public htmlviewer() { initializecomponent(); if (!designerproperties.getisindesignmode(this)) // if not in design mode...do work. populatecb(); }
depending on how dependency properties setup, may not handling null , causing issues; if above code apply.
Comments
Post a Comment