Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 运行Project夏威夷示例应用程序时System.Reflection.TargetInvocationException异常_C#_Windows Phone 7_Reflection - Fatal编程技术网

C# 运行Project夏威夷示例应用程序时System.Reflection.TargetInvocationException异常

C# 运行Project夏威夷示例应用程序时System.Reflection.TargetInvocationException异常,c#,windows-phone-7,reflection,C#,Windows Phone 7,Reflection,我正在使用夏威夷SDK项目创建语音到文本应用程序。我运行了示例项目,在启动时引发了以下异常 System.Reflection.TargetInvocationException was unhandled by user code HResult=-2146232828 Message=Exception has been thrown by the target of an invocation. Source=mscorlib InnerException: System.MethodAc

我正在使用夏威夷SDK项目创建语音到文本应用程序。我运行了示例项目,在启动时引发了以下异常

System.Reflection.TargetInvocationException was unhandled by user code
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
InnerException: System.MethodAccessException
   HResult=-2146233072
   Message=Attempt by security transparent method 'System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)' to access security critical method 'System.IO.File.Exists(System.String)' failed.
   Source=mscorlib
   InnerException: 
我看到异常描述,但我无法找到适当的解决方案。这是发生错误的块代码

 try
        {
            bool fileExists = (bool)existsMethodInfo.Invoke(null, new object[] { configFilePath });

            if (fileExists)
            {
                IEnumerable<string> lines = (IEnumerable<string>)readLinesMethodInfo.Invoke(null, new object[] { configFilePath });
                foreach (string line in lines)
                {
                    if (!string.IsNullOrEmpty(line))
                    {
                        return line;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
试试看
{
bool fileExists=(bool)existsMethodInfo.Invoke(null,新对象[]{configFilePath});
如果(文件存在)
{
IEnumerable lines=(IEnumerable)readLinesMethodInfo.Invoke(null,新对象[]{configFilePath});
foreach(行中的字符串行)
{
如果(!string.IsNullOrEmpty(行))
{
回流线;
}
其他的
{
打破
}
}
}
}
进行这些调用的函数的摘要是“函数在指定文件中查找设置时使用。如果不存在,则返回默认值。由于CA2140分析规则,需要[SecurityCritical]属性