System.Reflection.TargetInvocationException when running Project Hawaii Sample app
I am using the Hawaii project SDK to create a Speech to Text app. I ran the sample project and the following exception was thrown at startup.
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:
I see the description of the exception, however I cannot find a suitable solution. Here is the code of the block in which the error occurred.
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;
}
}
}
}
The summary of the function that makes these calls is "Function is used in a. It looks for settings in the specified file. If it does not exist, it returns the default. The [SecurityCritical] attribute must be present because of the CA2140 parsing rule."
+3
source to share
No one has answered this question yet
Check out similar questions: