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 replacement.
Also, please forgive any ignorance, I am fairly new to IL but not C#. I
would also like to note that the code works completely fine before I
replace the namespace with a new name, so it is 100% something wrong with
the namespace changing (even when I didn't change System and did something
like System.Net -> System.MyNet or System.Net.Sockets ->
System.Net.MySockets).
Namespace replacement 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");
}
}
}
Test code after importing the library:
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();
}
}
}
Thanks!
--
--
--
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.