上周我关闭了我的工作VS 2012(11.0)项目,今天我无法加载Windows窗体设计器。相反,我收到此消息:“为了防止在加载设计器之前可能的数据丢失,必须解决以下错误:路径中的非法字符。”没有选项可以忽略该消息。我仍然可以运行我的代码,它工作正常。请准备一个冗长的调用堆栈:
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.VisualStudio.Platform.VsAppDomainManager.d__1.MoveNext()
at Microsoft.VisualStudio.Platform.VsAppDomainManager.InnerResolveHandler(String name)
at Microsoft.VisualStudio.Platform.VsAppDomainManager.ResolveHandler(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) )
Visual Studio没有给我任何更多细节,烦人的(我甚至不知道它指的是哪条“路径”),但我可以添加更多信息:
在我的Settings.settings中,我有一个指向日志文件目录的字符串logFileDir
。该路径当前有效,当我运行我的程序时,它正确更新了日志文件。
表单加载方法很简单,如下所示:
if (Properties.Settings.Default.logFileDir != null)
{
_logFileDir = Properties.Settings.Default.logFileDir;
PopulateLstDirectory();
}
else
{
_logFileDir = null;
}
当我运行代码时,调用堆栈有时会增长,但新行看起来与我上面粘贴的现有行重复。
调用堆栈的第二高行说了一些关于Path.Combine的内容 - 我唯一一次调用该函数是在我的表单上的某个按钮的Click()方法中:
string pathString = Path.Combine(_logFileDir, logFileName);
答案 0 :(得分:0)
啊,当它发生时这很烦人。 您将必须通过form.designer文件来查看问题所在。 在代码视图中 - 编译您的程序并查看错误,它将告诉您问题所在。只需进入.designer文件并更正错误。