Ah! Thank you so much for the reply. So, if I understand correctly, I will not be able to solve this with Cecil, but will need to build out my own version of the System.dll from Mono?
On Thursday, January 8, 2015 at 1:10:33 AM UTC-8, Jb Evain wrote: > > Hi Brent, > > This one is pretty simple : some code for the socket support is > implemented in the runtime (icalls), and are identified by assembly > name + full type name. > > So if you rename the namespace of the type defining the icall, the > runtime won't be able to map the icalls properly. > > Jb > > On Thu, Jan 8, 2015 at 2:09 AM, Brent Farris <[email protected] > <javascript:>> wrote: > > (Sorry if this posts 2x, the other post didn't show up/went off into > > oblivion) > > > > Hello, I am curious if anyone happens to know why when I change the > > namespace of System.Net.Sockets to anything else why it would stop > working? > > > > I have tested other classes and methods and when I put in a Try/Catch I > > found that the issue was that it was unable to call the internal method > > "Socket_internal". I am sure that this is a problem with any of the > > internal methods as well. I am doing a very simple namespace > repalcement. > > Also, please forgive any ignorance, I am fairly new to IL but not C#. I > > would like to note that I have tried this by removing the entire foreach > > loop in the first code snipit and it worked just fine with that library > > (MySystem.dll) using System.Net.Sockets (was not refrencing the normal > > System). So I must be doing something wrong when I rename (or breaking > > somekind of link to internal functions). I have tested this by renaming > it > > to System.MyNet.Sockets as well as System.Net.MySockets and all rename > > attempts at any level cause the failure. > > > > Namespace re-write code: > > using Mono.Cecil; > > > > namespace CecilNamespaceRenamer > > { > > class Program > > { > > static void Main (string[] args) > > { > > var assembly = AssemblyDefinition.ReadAssembly > > (@"/path/to/dir/System.dll"); > > var name = assembly.Name; > > > > name.Name = "MySystem.dll"; > > > > foreach (var t in assembly.MainModule.Types) > > { > > if (t.Namespace.StartsWith("System")) > > t.Namespace = t.Namespace.Replace ("System", > > "MySystem"); > > } > > > > assembly.Write(@"/path/to/dir/MySystem.dll"); > > } > > } > > } > > > > Library test code: > > using System; > > using MySystem.Net; > > using MySystem.Net.Sockets; > > > > namespace TEsT > > { > > class MainClass > > { > > public static void Main (string[] args) > > { > > TcpListener tcpListener = null; > > > > try > > { > > tcpListener = new > TcpListener(IPAddress.Parse("127.0.0.1"), > > 15937); > > tcpListener.Start(); > > } > > catch (MissingMethodException e) > > { > > Console.WriteLine(e.Message); > > } > > > > Console.WriteLine("TEST"); > > Console.ReadKey(); > > tcpListener.Stop(); > > } > > } > > } > > > > > > -- > > -- > > -- > > mono-cecil > > --- > > You received this message because you are subscribed to the Google > Groups > > "mono-cecil" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > For more options, visit https://groups.google.com/d/optout. > -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
