I have a stupid WinCE application where I’m just trying to force an exception and get the exception message to be retrieved from the System.SR.dll which gets deployed to the device.
The code that I have throwing an exception is the following:
TcpClient client = new TcpClient("abcd", 1234);
But when the SocketException tries to resolve it’s message, it throws a FileNotFoundException with the following tacktrace:
at System.Reflection.Assembly.InternalGetSatelliteAssembly()
at System.Reflection.Assembly.GetSatelliteAssembly()
at System.Resources.ResourceManager.InternalGetResourceSet()
at System.Resources.ResourceManager.GetString()
at System.Resources.ResourceManager.GetString()
at System.SRSupport.HasString()
at System.SRSupport.HasString()
at System.SR.HasString()
at System.Net.Sockets.SocketException.makeMessage()
at System.Net.Sockets.SocketException..ctor()
at System.Net.Dns.ResolveInternal()
at System.Net.Dns.GetHostEntry()
at System.Net.Sockets.TcpClient.Connect()
at System.Net.Sockets.TcpClient..ctor()
at WinCeMessage.Com.SocketBlaster.Blast()
at WinCeMessage.Form1.button1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at WinCeMessage.Program.Main()
(I believe) The file where these messages are kept is the System.SR.dll, which gets deployed to the device when I run it in Visual Studio. I docked the emulator, and verified that file is present.
This is the code from System.SR.dll throwing the exception:
internal Assembly InternalGetSatelliteAssembly(CultureInfo culture, Version version, bool throwOnFileNotFound)
{
if (culture != null)
{
Assembly assembly = null;
AssemblyName name = this.GetName();
if (name != null)
{
name.Version = version;
name.CultureInfo = culture;
if (name.Name != null)
{
name.Name = string.Concat(name.Name, ".resources");
name.CodeBase = null;
}
try
{
StackCrawlMark stackCrawlMark = StackCrawlMark.LookForMyCaller;
assembly = Assembly.BCL_System_Reflection_Assembly_LoadFromName(name, false, null, ref stackCrawlMark);
}
catch (IOException oException)
{
assembly = null;
}
if (assembly != null)
{
if (assembly == this)
{
if (!throwOnFileNotFound)
{
return null;
}
else
{
throw new FileNotFoundException();
}
}
}
else
{
if (!throwOnFileNotFound)
{
return null;
}
else
{
throw new FileNotFoundException();
}
}
}
return assembly;
}
else
{
throw new ArgumentNullException();
}
}
I ended up making a new solution, that one seemed broken for some reason.