envdte.dte.documents每次访问时每次都可以访问,
我正在尝试存储Visual Studio环境中的打开文档。 该代码适用于某些解决方案,但是我有1个解决方案,它总是会引发异常。 我试图等待某种初始化,但是随着时间的推移没有任何变化。 一旦我发现例外,当我再次致电该物业时,这很好。 我做错了什么?
internal static IList<Document> GetOpenedDocuments(DTE service)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (service == null)
{
throw new ArgumentNullException(nameof(service));
}
List<Document> openedDocuments = new List<Document>();
foreach (Document document in service.Documents)
{
if (document != null)
{
openedDocuments.Add(document);
}
}
return openedDocuments;
}
访问service.documents
总是第一次崩溃。 堆栈痕迹的顶部:
在envdte.documents.getEnumerator()
中
异常消息中:
系统找不到指定的文件。 (Hresult的例外:0x80070002)
感谢您的帮助!
I'm trying to store the opened documents from the Visual Studio environment.
The code works for some solutions but I have 1 solution where it always throws an exception.
I have tried to wait for some kind of initialization but nothing changes over time.
As soon as I catch the exception, when I call the property again it's fine.
What do I do wrong?
internal static IList<Document> GetOpenedDocuments(DTE service)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (service == null)
{
throw new ArgumentNullException(nameof(service));
}
List<Document> openedDocuments = new List<Document>();
foreach (Document document in service.Documents)
{
if (document != null)
{
openedDocuments.Add(document);
}
}
return openedDocuments;
}
Accessing service.Documents
always crashes the first time.
Top of stack trace:
at EnvDTE.Documents.GetEnumerator()
at XXX.FileHelper.GetOpenedDocuments(DTE service) in
Exception message:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论