Red Gate forums :: View topic - Unusual and erroneus System.IO.FileNotFoundException error
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Unusual and erroneus System.IO.FileNotFoundException error

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
ak98



Joined: 15 Aug 2011
Posts: 4

PostPosted: Mon Aug 15, 2011 9:51 am    Post subject: Unusual and erroneus System.IO.FileNotFoundException error Reply with quote

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:
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6645

PostPosted: Mon Aug 15, 2011 11:09 am    Post subject: Reply with quote

Probably. SmartAssembly obfuscation can change the class name of the Windows Form and that means it has to change the name of the corresponding resource file for that form. Normally this is working just fine but we have had a few reports in some cases that localized resources may not get renamed, for instance if you have a Form1.FR-fr.resources file it may not get renamed.

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.
Back to top
View user's profile Send private message
ak98



Joined: 15 Aug 2011
Posts: 4

PostPosted: Tue Sep 06, 2011 2:11 am    Post subject: Reply with quote

I found that the path from my "SetEnv.cmd" did not include C:\Program Files\Microsoft SDKs\Windows\v7.0A only C:\Program Files\Microsoft SDKs\Windows\v7.1 which somehow did not contain resgen.exe. So in effect the resources were never compiled into the final assemblies.
Interestingly when build with VS it was OK, so only commandline builds failed.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group