Software development, .Net, SQL Server, TDD, Agile, Community and other Odds and Sods
Mitch Wheat has been working as a professional programmer since 1984, graduating with a honours degree in Mathematics from Warwick University, UK in 1986. He moved to Perth in 1995, having worked in software houses in London and Rotterdam. He has worked in the areas of mining, electronics, research, defence, financial, GIS, telecommunications, engineering, and information management. Mitch has worked mainly with Microsoft technologies (since Windows version 3.0) but has also used UNIX. He holds the following Microsoft certifications: MCPD (Web and Windows) using C# and SQL Server MCITP (Admin and Developer). His preferred development environment is C#, .Net Framework and SQL Server. Mitch has worked as an independent consultant for the last 10 years, and is currently involved with helping teams improve their Software Development Life Cycle. His areas of special interest lie in performance tuning
Sunday, June 22, 2008
What does the "Could not find resource assembly" error message mean?
If you are developing for a mobile device using the .NET Compact Framework and you get either of these error messages: "Could not find resource assembly" or “An error message cannot be displayed because an optional resource assembly containing it cannot be found”, the primary error is not caused because it could not find the resource assembly. [Both error messages are exactly the same. The first one was used in .NET CF V1 and second one is from .NET CF V2]
Basically, this means that some exception has occurred in your application for which a corresponding error message string could not be loaded due to a missing language dependent resource assembly. Having the actual error message would obviously be helpful in debugging what went wrong.
Why is the resource assembly missing? Quoting directly from the .NET Compact Framework team blog:
“Since the user is never expected to see this error message if the program works as expected and all exceptions are handled appropriately, it was decided (due to size constraints) that the resource assembly that has these error strings are never put on a user's device. Thus the main target audience of these error strings are developers who would like to debug issues. Hence, when you do an F5 deploy onto the device, the System.SR.dll assembly which have these error strings are copied to the device and the developer can see the error messages. But in case .Net Compact Framework is installed from a redistributable or you are using .Net Compact Framework that come with the device, the System.SR.dll is not present on the device. Hence, if the application did come upon an exceptional condition that wasn't handled by the application, this "Could not find resource assembly" message would be shown to the user.”
Personally, I think it was a mistake to not install the English resource assemblies by default. If you install the System.SR cab for your language then this error message should be replaced by the localized error message for what actually went wrong.
If Visual Studio does not install the SR cab when you deploy your solution, you can manually copy it to the device and run it there. Note: The cabs are named System_SR_
With Visual Studio 2005 installed all the SR cabs can be found here:
C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v2.0\WindowsCE\Diagnostics
Or if you installed from a distributable they can be found here:
MSN, Email: mitch døt wheat at gmail.com