C# 从.net程序集导入的函数在windows 8上始终返回true

C# 从.net程序集导入的函数在windows 8上始终返回true,c#,.net,reflection,import,boolean,C#,.net,Reflection,Import,Boolean,我在运行时将函数从在Windows7 64位上编译的.NETDLL导入到代码中 伪: delegate bool Test(int i); var assembly = Assembly.LoadFrom(...); var type = assembly.GetType(...); var method = type.GetMethod(...); Test test = (Test) Delegate.CreateDelegate(typeof(Test), method); 现在,当我

我在运行时将函数从在Windows7 64位上编译的.NETDLL导入到代码中

伪:

delegate bool Test(int i);

var assembly = Assembly.LoadFrom(...);
var type = assembly.GetType(...);
var method = type.GetMethod(...);
Test test = (Test) Delegate.CreateDelegate(typeof(Test), method);
现在,当我在windows 7上调用导入的函数(我在windows 7上编译了所有内容)时,它的工作方式与预期的一样,然而,当我在windows 8(64位)上调用它时,它总是返回true,即使该函数只执行“返回false”。在这两种情况下,函数似乎都正确导入。我和他核实过了

Console.WriteLine(test.Method.ToString());
它会输出函数的名称和类型

知道是什么引起的吗

编辑:

好的,这是代码。仍然缩短和简化,但没有任何重要的删节

dll代码:

namespace InputController_Scripts
{
    class script
    {
        public static bool Test_Paused(int color)
        {
            return false; 
        }
    }
}
程序代码:

delegate bool DTest(int color);

Assembly assembly = Assembly.LoadFrom($@"{extraPath}{Config.GameName.ToLower()}.dll");
Type type = assembly.GetType("InputController_Scripts.script");
MethodInfo mInfo = type.GetMethod("Test_Paused");
DTest test = (DTest)Delegate.CreateDelegate(typeof(DTest), mInfo);

Console.WriteLine(test(123)); //false on win7, true on win8
编辑:


好的,我发现了问题。这与反思无关(对不起,伙计们,是的,我错认为“不删掉任何重要内容”)。长话短说,Windows8有不同的区域设置,配置文件中的“0,10”被解释为“10”,这把一切都搞砸了。我把它改为“0.10”,现在它可以工作了。

问题在于你的代码。如果在Windows 8上出现所有反映的
bool
代理都将返回
true
true only
的问题,许多计算机上的大量现有代码将被破坏。显示您的实际代码。谢谢。我还是不相信。是否确实加载了正确的程序集,而不是另一个返回
true
的版本?是的,我是肯定的。我正在考虑在windows 8上重新编译dll,也许这会有所帮助。@Swift:尝试像往常一样在windows 7上重新编译dll,但更改代码以引发异常,而不是返回
false
。如果Windows 8上的代码仍然生成一个
true
值,我认为这是一个强烈的迹象,表明它没有调用您认为它是的方法,或者没有指向正确的DLL,或者可能以其他方式使用了错误的DLL(是否可能程序集的旧版本已经加载到内存中?)非常感谢你的建议,但我错误地认为这与此有关。更新了op。