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_ for non windows mobile devices (e.g. CE 4.2) and System_SR__wm for windows mobile devices.

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:
C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\Diagnostics




    

Powered by Blogger