Posted 20 years ago by Jake Pearson - Software Developer, Alion Science and Technology
Avatar
Hi,
I was able to get a Win32Exception if I create a large number of SyntaxEditor objects. I believe I can mitigate the problem by cacheing the editors. Here is the stack trace:

Unhandled Exception: System.ComponentModel.Win32Exception: Element not found
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at System.Drawing.Icon..ctor(Stream stream)
at ActiproSoftware.Products.Resources.GetIcon(Assembly assembly, String name)
at ActiproSoftware.Products.SyntaxEditor.Resources.GetIcon(IconResource icon)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.ResetReflectionImageList()
at ActiproSoftware.SyntaxEditor.SyntaxEditor..ctor()
at MAAD.Utilities.CodeEditor.CodeEditor..ctor() in c:\documents and settings\jpearson.maad\my documents\visual studio projects\simulator\maad.utilities.codeeditor\codeeditor.cs:line 46
at MAAD.Utilities.CodeEditor.CSharpEditor..ctor() in c:\documents and settings\jpearson.maad\my documents\visual studio projects\simulator\maad.utilities.codeeditor\csharpeditor.cs:line 31
at MAAD.Network.Utilities.VisualComponents.TargetPanel.InitializeComponent() in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TargetPanel.cs:line 85
at MAAD.Network.Utilities.VisualComponents.TargetPanel..ctor() in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TargetPanel.cs:line 49
at MAAD.Network.Utilities.VisualComponents.TaskPanel.Populate() in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TaskPanel.cs:line 922
at MAAD.Network.Utilities.VisualComponents.TaskObjectPanel.Populate() in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TaskObjectPanel.cs:line 345
at MAAD.Utilities.VisualComponents.BaseEditablePanel.LoadObject(IEditable editable) in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Utilities\VisualComponents\BaseEditablePanel.cs:line 66
at MAAD.Network.Utilities.VisualComponents.TaskObjectPanel.ShowObject(ENavigationDirection direction) in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TaskObjectPanel.cs:line 473
at MAAD.Network.Utilities.VisualComponents.TaskObjectPanel.buttonDirection_Click(Object sender, EventArgs e) in C:\Documents and Settings\jpearson.MAAD\My Documents\Visual Studio Projects\Simulator\MAAD.Network\Utilities\VisualComponents\TaskObjectPanel.cs:line 415
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)

thanks,
Jake

Comments (3)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That almost seems like a bug in the .NET framework. Our GetIcon method, the last method of ours that is called, is very simple. Here's the code:
string fullName = name + ".ico";
Stream stream = assembly.GetManifestResourceStream(fullName);
return new Icon(stream);
As you can see, there's nothing tricky going on there. Maybe this is something you could pass on to Microsoft's support to see why that might occur.


Actipro Software Support

Posted 20 years ago by Jake Pearson - Software Developer, Alion Science and Technology
Avatar
Hi,
I posted on one of Microsoft's newsgroups. I got a response, but not for the question I asked. I tried something else. I overrode the ResetReflectionImageList with the following code:

private static ImageList StaticReflectionImageList = null;
/// <summary>
/// Reset Reflection Image List
/// </summary>
public override void ResetReflectionImageList()
{
if(StaticReflectionImageList == null)
{
base.ResetReflectionImageList ();
StaticReflectionImageList = ReflectionImageList;
}
else
{
ReflectionImageList = StaticReflectionImageList;
}
}

That way I do not keep reallocating the image list. It seems to fix the problem.

thanks,
Jake
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We'll implement something similar for the next maintenance release.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.