I get "Error rendering control" error that only happens when I place the control on the webform in desgin-mode, if I run the page the control is displayed correctly.
The above statement is not important, this error happens because the returned toolbars object is null.
After debugging, the problem is in a function that is called from CeateChildControls():
public static ToolBars LoadToolbarsFromConfigFile()
{
ToolBars toolbars;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string resource = "Editor.ConfigFiles.ToolBars.xml";
using (Stream stream = executingAssembly.GetManifestResourceStream(resource))
{
XmlSerializer serializer = new XmlSerializer(typeof(ToolBars));
toolbars = (serializer.Deserialize(stream)) as ToolBars;
}
return toolbars;
}
the toolbars returns null! (in design-mode)
But when I run the page, toolbars returns appropriate data.
If you need some more info about my code please ask.
Update:
It must be something with Assembly, If I use file stream instead with specified file, it does work.
Another UPDATE:
I've modified my code a bit, and added "dataset" for test purpose:
using (DataSet ds = new DataSet())
{
ds.ReadXml(typeof(TheEditor).Assembly.GetManifestResourceStream("Editor.ConfigFiles.ToolBars.xml"));
//show message box to see if it works
System.Windows.Forms.MessageBox.Show(ds.Tables.Count.ToString());
}
Another thing that I noticed, all above happens when I add my control to a new website project, but if I set debug property of control's project to start external program (i start visual studio) , and there I create a new project and add the control everything works.