我在这个问题上找到了不少谷歌点击,但找不到解决方案.
当我尝试使用ikvmstub.exe我将.NET接口转换为Java存根时出现以下错误:
C:\public\ikvm-0.44.0.5\bin\ikvmstub.exe NET_Interface.dll
Error: unable to load assembly 'NET_Interface.dll' as it depends on a higher ver
sion of mscorlib than the one currently loaded
Run Code Online (Sandbox Code Playgroud)
NET_Interface.dll 取决于框架版本4.此版本安装在我的机器上.
我该如何解决这个问题?
谢谢你的时间.
今天我很震惊,有比较内心的倾向Buffer.BlockCopy,Array.CopyTo. 我很好奇,看看是否在幕后Array.CopyTo被召唤Buffer.BlockCopy.这背后没有实际用途,我只想进一步了解C#语言及其实现方式.不要跳枪并指责我微观优化,但你可以指责我好奇!
当我在mscorlib.dll上运行ILdasm时,我收到了这个 Array.CopyTo
.method public hidebysig newslot virtual final
instance void CopyTo(class System.Array 'array',
int32 index) cil managed
{
// Code size 0 (0x0)
} // end of method Array::CopyTo
Run Code Online (Sandbox Code Playgroud)
这个 Buffer.BlockCopy
.method public hidebysig static void BlockCopy(class System.Array src,
int32 srcOffset,
class System.Array dst,
int32 dstOffset,
int32 count) cil managed internalcall
{
.custom instance void System.Security.SecuritySafeCriticalAttribute::.ctor() = ( 01 00 00 00 )
} // end of method Buffer::BlockCopy
Run Code Online (Sandbox Code Playgroud)
坦率地说,这令我感到困惑.我从未在我没有创建的dll/exe上运行ILdasm.这是否意味着我将无法看到这些功能是如何实现的?搜索周围只显示了一个stackoverflow问题 …
我正在考虑实例方法Object.Equals(Object).使用反射,可以将此方法的IL作为字节数组获取,如下所示:
var mi = typeof(object).GetMethod("Equals", BindingFlags.Instance | BindingFlags.Public);
var mb = mi.GetMethodBody();
var bytes = mb.GetILAsByteArray();
Run Code Online (Sandbox Code Playgroud)
我有两台PC:一台是运行Windows XP的32位机器,另一台是Windows 7的64位机器.两台机器都安装了.NET Framework 4.0.30319 SP1Rel.
在x86机器上,生成的数组是:
[0]: 2
[1]: 3
[2]: 40
[3]: 122
[4]: 67
[5]: 0
[6]: 6
[7]: 42
Run Code Online (Sandbox Code Playgroud)
但是在x64机器上,我得到了这个:
[0]: 2
[1]: 3
[2]: 40
[3]: 123
[4]: 67
[5]: 0
[6]: 6
[7]: 42
Run Code Online (Sandbox Code Playgroud)
第四个字节是不同的.
现在我知道mscorlib在64位平台上有两种版本.然而,ILDASM揭示了这种方法的IL在风味之间和机器之间是相同的.在x64机器上,我在"任何CPU"和"x86"都定位了上面的代码,但结果是一样的.
所以我的问题是,任何人都可以解释这两台机器之间的差异吗?
UPDATE
这是Object.Equals(Object)的C#和IL:
public virtual bool Equals(object obj)
{
return RuntimeHelpers.Equals(this, obj);
}
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: call bool …Run Code Online (Sandbox Code Playgroud) 我尝试使用Roslyn编译一些代码,但收到以下错误消息:
CS0012:类型'Func <,>'在未引用的程序集中定义.您必须添加对程序集'System.Runtime,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用.
我仍然Func<, >对这条消息感到疑惑,因为应该在mscorelib而不是在System.Runtime.我已经搜索过这个bug,只找到了一个应该有用的热修复,但是没有.
有没有人与.net 4.5.1和最新的Roslyn版本有类似的问题?
谢谢!
我想为mscorlib添加一些方法.例如:
string abc;
abc.IsNumeric()
我希望可以解释我的问题.
我正在挖掘MSCoreLib,我发现了一些有趣的东西.
我很困惑这甚至是如何工作的.
(参见http://referencesource.microsoft.com/#mscorlib/system/math.cs第32行)
// This table is required for the Round function which can specify the number of digits to round to
private static double[] roundPower10Double = new double[] {
1E0, 1E1, 1E2, 1E3, 1E4, 1E5, 1E6, 1E7, 1E8,
1E9, 1E10, 1E11, 1E12, 1E13, 1E14, 1E15
};
public const double E = 2.7182818284590452354;
Run Code Online (Sandbox Code Playgroud)
看起来他们正在创建一个双数组.然后,为每个值乘以1 * E * nth.这是出现的情况,但他们没有使用任何运营商?
这个黑魔法是什么?
这是我的代码:
dim myArrayList
function addName
Wscript.StdOut.WriteLine "What is your Quarterback's name?"
n = Wscript.StdIn.ReadLine
Wscript.StdOut.WriteLine "Attempts: "
a = Wscript.StdIn.ReadLine
Wscript.StdOut.WriteLine "Completions: "
c = Wscript.StdIn.ReadLine
Wscript.StdOut.WriteLine "Yards: "
y = Wscript.StdIn.ReadLine
Wscript.StdOut.WriteLine "Touchdowns: "
t = Wscript.StdIn.ReadLine
Wscript.StdOut.WriteLine "Interceptions: "
i = Wscript.StdIn.ReadLine
Set myArrayList = CreateObject( "System.Collections.ArrayList" )
myArrayList.Add n
myArrayList.Add a
myArrayList.Add c
myArrayList.Add y
myArrayList.Add t
myArrayList.Add i
end function
addname()
function show
for i = 1 to myArrayList.count
Wscript.StdOut.WriteLine myArrayList(i)
next
end function
show()
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:“ …