C# 尝试在.net4 don';似乎不起作用
我正在.net4上运行的一个小型测试解决方案上进行Dll重定基址的实验,该解决方案由一个小型.exe和三个小型.Dll组成。程序集引用设置正确,程序编译和运行正常 这个练习的目的是检查重定基调是如何工作的,这样我就可以将它与ngen结合起来,并在我正在进行的一个大型项目中提高性能 我尝试了许多不同的方法重新设置DLL的基址,并使用vmmap、visual studio模块调试器窗口和process explorer监视结果;到目前为止,还没有成功的案例:C# 尝试在.net4 don';似乎不起作用,c#,.net,visual-studio-2010,dll,rebasing,C#,.net,Visual Studio 2010,Dll,Rebasing,我正在.net4上运行的一个小型测试解决方案上进行Dll重定基址的实验,该解决方案由一个小型.exe和三个小型.Dll组成。程序集引用设置正确,程序编译和运行正常 这个练习的目的是检查重定基调是如何工作的,这样我就可以将它与ngen结合起来,并在我正在进行的一个大型项目中提高性能 我尝试了许多不同的方法重新设置DLL的基址,并使用vmmap、visual studio模块调试器窗口和process explorer监视结果;到目前为止,还没有成功的案例: 我已经将Dll1.DLL、Dll2.DL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Dll1;
using Dll2;
using Dll3;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "Poodle";
Console.ReadLine();
//Thread.Sleep(10000);
Blah();
}
static void Blah()
{
Console.WriteLine(Class2.shrooms(5, 'h'));
Class3.teenAngst();
Class1.Wait();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll1
{
public static class Class1
{
public static void Wait()
{
Console.ReadLine();
Console.Write(" ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll2
{
public static class Class2
{
public static string shrooms(int argc, char argv)
{
return "Ranchdaddyx ";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll3
{
public static class Class3
{
public static void teenAngst()
{
Console.Write("Belonging ");
}
}
}
Class1.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Dll1;
using Dll2;
using Dll3;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "Poodle";
Console.ReadLine();
//Thread.Sleep(10000);
Blah();
}
static void Blah()
{
Console.WriteLine(Class2.shrooms(5, 'h'));
Class3.teenAngst();
Class1.Wait();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll1
{
public static class Class1
{
public static void Wait()
{
Console.ReadLine();
Console.Write(" ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll2
{
public static class Class2
{
public static string shrooms(int argc, char argv)
{
return "Ranchdaddyx ";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll3
{
public static class Class3
{
public static void teenAngst()
{
Console.Write("Belonging ");
}
}
}
Class2.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Dll1;
using Dll2;
using Dll3;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "Poodle";
Console.ReadLine();
//Thread.Sleep(10000);
Blah();
}
static void Blah()
{
Console.WriteLine(Class2.shrooms(5, 'h'));
Class3.teenAngst();
Class1.Wait();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll1
{
public static class Class1
{
public static void Wait()
{
Console.ReadLine();
Console.Write(" ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll2
{
public static class Class2
{
public static string shrooms(int argc, char argv)
{
return "Ranchdaddyx ";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll3
{
public static class Class3
{
public static void teenAngst()
{
Console.Write("Belonging ");
}
}
}
Class3.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Dll1;
using Dll2;
using Dll3;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "Poodle";
Console.ReadLine();
//Thread.Sleep(10000);
Blah();
}
static void Blah()
{
Console.WriteLine(Class2.shrooms(5, 'h'));
Class3.teenAngst();
Class1.Wait();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll1
{
public static class Class1
{
public static void Wait()
{
Console.ReadLine();
Console.Write(" ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll2
{
public static class Class2
{
public static string shrooms(int argc, char argv)
{
return "Ranchdaddyx ";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dll3
{
public static class Class3
{
public static void teenAngst()
{
Console.Write("Belonging ");
}
}
}
.Net.dll与它们的非托管等价物截然不同。老实说,我不认为重新定基是相关的 查看这篇MSDN文章。除其他外,这会鼓励您不要重新设定基准。并给出了至少一个令人信服的理由(这可能会使强签名程序集的签名无效)。本文还讨论了NGEN的潜在好处(以及您的链接):
无需重新设置JIT编译代码的基础: JIT编译的代码没有重定基址问题,因为地址 在运行时根据代码在内存中的位置生成。 此外,MSIL很少受到基址未命中的影响,因为MSIL 引用是基于令牌的,而不是基于地址的。因此,当 使用JIT编译器,系统对基址具有弹性 碰撞
原来(地址空间布局随机化)是我困惑的罪魁祸首。显然你可以关掉它,但是你牺牲了安全/为自己做了很多工作。我认为整个冒险是一次失败的实验。这篇文章说我应该避免在自动意义上重新设置,并且在使用NGEN时,我应该选择自己的基地址。事先选择基址可以避免在运行时重定基址,这是一个非常昂贵的过程。让我沮丧的是,无论我做了什么,这都不会发生。我正在尝试重新设置ngen代码的基础。重定MSIL代码的基调只是试图让重定基调发挥作用的一个练习。即使没有必要,也有可能吗?