Unusual and erroneus System.IO.FileNotFoundException error
ak98
Posts: 8 Bronze 2
I have a DN2 application that when processed by smart assembly , fails to run with the following error as reported by the automated reporting from SA. Note that the error mentions DN4 System.Drawing. The machine has DN4 installed(its the development machine)
System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Further dicking around and debugging has tracked the error down to Resource manager
i.e. System.Resources.ResourceManager.GetObject(String name)
Because of renaming / obfuscation the resource which is a System.Drawing.Image cannot be loaded from the local form resource.
I wonder why it is translated to a System.IO.FileNotFoundException.
Here is obfuscated and then decoded stacktrace
I will not be able to use SA if this error cannot be eradicated.
I think that the SA obuscation has corrupted the Resource lookup on winform local resources.
StackTrace:
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
at #im.#ot.#Vz() in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.Designer.cs:line 34
at #im.#ot..ctor(-\* ) in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.cs:line 53
at #im.#5o.#ML(Object , EventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 984
at #im.#nt.#M3(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\Paint\PanelInteractionPainter.cs:line 72
at #im.#5o.OnMouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 2030
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at #im.#5o.WndProc(Message& ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 1720
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
StackTrace:
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
at CurrentPatient.QPResults.InitializeComponent() in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.Designer.cs:line 34
at CurrentPatient.QPResults..ctor(-\* ) in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.cs:line 53
at CurrentPatient.TaskbarNotifier.HandlerQPRClick(Object , EventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 984
at CurrentPatient.PanelInteractionPainter.MouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\Paint\PanelInteractionPainter.cs:line 72
at CurrentPatient.TaskbarNotifier.OnMouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 2030
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at CurrentPatient.TaskbarNotifier.WndProc(Message& ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 1720
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Further dicking around and debugging has tracked the error down to Resource manager
i.e. System.Resources.ResourceManager.GetObject(String name)
Because of renaming / obfuscation the resource which is a System.Drawing.Image cannot be loaded from the local form resource.
I wonder why it is translated to a System.IO.FileNotFoundException.
Here is obfuscated and then decoded stacktrace
I will not be able to use SA if this error cannot be eradicated.
I think that the SA obuscation has corrupted the Resource lookup on winform local resources.
StackTrace:
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
at #im.#ot.#Vz() in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.Designer.cs:line 34
at #im.#ot..ctor(-\* ) in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.cs:line 53
at #im.#5o.#ML(Object , EventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 984
at #im.#nt.#M3(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\Paint\PanelInteractionPainter.cs:line 72
at #im.#5o.OnMouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 2030
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at #im.#5o.WndProc(Message& ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 1720
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
StackTrace:
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
at CurrentPatient.QPResults.InitializeComponent() in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.Designer.cs:line 34
at CurrentPatient.QPResults..ctor(-\* ) in K:\VS2011\DCPSB\DCP\UI\Forms\QPResults.cs:line 53
at CurrentPatient.TaskbarNotifier.HandlerQPRClick(Object , EventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 984
at CurrentPatient.PanelInteractionPainter.MouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\Paint\PanelInteractionPainter.cs:line 72
at CurrentPatient.TaskbarNotifier.OnMouseClick(MouseEventArgs ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 2030
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at CurrentPatient.TaskbarNotifier.WndProc(Message& ) in K:\VS2011\DCPSB\DCP\UI\Forms\TaskbarNotifier.cs:line 1720
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
Comments
This is because out-of-the box, Visual Studio will automatically turn these resources into satellite resource DLLs, but of course there are ways to manipulate VS to embed the resources instead. So it may be worthwhile to find out the name of the resource it's trying to locate and that information should be in your debugger.
Interestingly when build with VS it was OK, so only commandline builds failed.