我下载了 MonoDroid 开发环境。如果我创建一个新的“Android 应用程序的 Mono”项目,或者如果我在 MonoDevelop 中导入一个示例项目,我会立即在消息日志中弹出以下两条错误消息(并且无法构建/运行该项目):
Error - 16:49:38 - Error running resgen
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.
at System.Convert.FromBase64String(String s)
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.GetProjectBuilder(TargetRuntime runtime, String toolsVersion, String file)
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.GetProjectBuilder()
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.RunTarget(IProgressMonitor monitor, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.SolutionItem.OnRunTarget(IProgressMonitor monitor, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.SolutionEntityItem.OnRunTarget(IProgressMonitor monitor, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.DefaultProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.ProjectServiceExtension.RunTarget(IProgressMonitor monitor, IBuildTarget item, String target, ConfigurationSelector configuration)
at MonoDevelop.Projects.SolutionItem.RunTarget(IProgressMonitor monitor, String target, ConfigurationSelector configuration)
at MonoDevelop.MonoDroid.MonoDroidProject.<RunResgen>b__13(Object )
Error - 16:49:38 - Parser database for project 'MonoA3 could not be loaded
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.
at System.Convert.FromBase64String(String s)
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.GetProjectBuilder(TargetRuntime runtime, String toolsVersion, String file)
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.GetProjectBuilder()
at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.<MonoDevelop.Projects.Extensions.IAssemblyReferenceHandler.GetAssemblyReferences>d__2.MoveNext()
at MonoDevelop.Projects.DotNetProject.<GetReferencedAssemblies>d__f.MoveNext()
at MonoDevelop.Projects.Dom.Serialization.ProjectCodeCompletionDatabase.UpdateFromProject()
at MonoDevelop.Projects.Dom.Serialization.ProjectCodeCompletionDatabase..ctor(Project project, ParserDatabase pdb)
at MonoDevelop.Projects.Dom.Serialization.ParserDatabase.LoadProjectDom(Project project)
at MonoDevelop.Projects.Dom.Parser.ProjectDomService.Load(Project project)
我多次卸载并重新安装了 MonoDevelop(V2.8.8.4,自动安装在德文版)和 MonoDroid(4.0.6),但仍然收到相同的错误消息(操作系统是 Win 7 Sp1)。在虚拟机(Win Vista,英文版)中,我可以运行它。我的问题是,我看不到导致问题的字符串。我在这里找到了导致此异常的代码块:
Process p = null;
try {
p = runtime.ExecuteAssembly (pinfo);
p.StandardInput.WriteLine (Process.GetCurrentProcess ().Id.ToString ());
string sref = p.StandardError.ReadLine ();
byte[] data = Convert.FromBase64String (sref);
MemoryStream ms = new MemoryStream (data);
BinaryFormatter bf = new BinaryFormatter ();
builder = new RemoteBuildEngine (p, (IBuildEngine) bf.Deserialize (ms));
} catch {
if (p != null) {
try {
p.Kill ();
} catch { }
}
throw;
}
使用 TargetRuntime 运行时,ProcessStartInfo pinfo。看起来进程返回了一个不正确的 Base64 字符串的 StandardError。如何访问此流程的 StandardError 输出?我来自 Java 世界,我对 Mono/.NET 很陌生。