简体   繁体   English

Visual Studio 2008 jQuery IntelliSense偶尔会失败,重新启动VS修复程序

[英]Visual Studio 2008 jQuery IntelliSense sporadically fails, restarting VS fixes

Right off the bat, this is not your standard "I can't get javascript IntelliSense to work in Visual Studio." 马上,这不是你的标准“我无法在Visual Studio中使用javascript IntelliSense。” For the record: 作为记录:

  • I'm using Visual Studio 2008 我正在使用Visual Studio 2008
  • I have installed SP 1 我安装了SP 1
  • I have installed the hotfix for -vsdoc.js documentation files KB958502 我已经为-vsdoc.js文档文件KB958502安装了修补程序

I am developing a suite of interrelated jQuery plugins to be packaged as resources in a class library. 我正在开发一套相互关联的jQuery插件,作为资源打包在类库中。 So within a directory, I have (as an example): 所以在一个目录中,我有(作为例子):

  • jquery-vsdoc.js jQuery的vsdoc.js
  • core.js core.js
  • plug1.js plug1.js
  • plug2.js plug2.js

In core.js, I have the following at the top of the file: 在core.js中,我在文件的顶部有以下内容:

/// <reference path="jquery-vsdoc.js" />

Then in each of the plug#.js, I have: 然后在每个插件#.js中,我有:

/// <reference path="jquery-vsdoc.js" />
/// <reference path="core.js" />

The IntelliSense works initially, even including the additions from core.js when working in the plugins. IntelliSense最初工作,甚至包括在插件中工作时core.js的添加。 However, sometimes the slightest change, even adding and removing a space from the reference XML tags, or pressing Ctrl-Shift-J, results in the dreaded "Error updating JScript IntelliSense: Client-side script IntelliSense information was not generated due to an error in an external script reference." 但是,有时最轻微的更改,甚至添加和删除参考XML标记中的空格,或按Ctrl-Shift-J,都会导致可怕的“更新JScript IntelliSense时出错:客户端脚本IntelliSense信息由于错误而未生成在外部脚本参考中。“ Except it was working with that external script reference just a second ago! 除了它在一秒钟前使用该外部脚本参考!

For the jquery-vsdoc.js, I am using Comment Version 1.3.2b (that's what it says in the file) from http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js . 对于jquery-vsdoc.js,我使用的是http://jqueryjs.googlecode.com/files/jquery-1.3.2-vsdoc2.js中的评论版本1.3.2b(这就是它在文件中所说的内容)。 I am omitting the version number from the file so that I don't have to change a bunch of references when it's inevitably updated. 我省略了文件中的版本号,这样我就不必更改一堆引用,当它不可避免地更新时。

So what could be the problem? 那可能是什么问题呢? Restarting Visual Studio is proving to be a horribly inelegant (and time-consuming) workaround. 重新启动Visual Studio被证明是一种非常不优雅(且耗时)的解决方法。

I dont know if this will help you, but I've encountered the following bug in VS 2008 JS intellisense: 我不知道这是否会对你有帮助,但我在VS 2008 JS intellisense中遇到了以下错误:

When adding jQuery as a reference in an external file, and then I update JS I get: 在外部文件中添加jQuery作为引用,然后我更新JS我得到:

'XmlHttpRequest is undefined' on the line: 行上的“XmlHttpRequest未定义”:

return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

It seems like the JS intellisense engine is actually executing some of the jQuery code (more than likely to inspect it so it can provide some more information about it). 似乎JS intellisense引擎实际上正在执行一些jQuery代码(更有可能检查它,因此它可以提供更多关于它的信息)。 However it looks like window.ActiveXObject is null to the engine, and so it falls into the 'new XMLHttpRequest()' block - which also fails. 但是它看起来像window.ActiveXObject对于引擎是空的,因此它属于'new XMLHttpRequest()'块 - 它也失败了。

I hacked a workaround that breaks all browsers except IE - so not a good solution. 我破解了除了IE之外的所有浏览器的解决方法 - 所以这不是一个好的解决方案。 My fix changes the following: 我的修复更改了以下内容:

    xhr: function()
    {
        // hack to fix VS 2008 intellisense... note this breaks any browser
        // except IE
        var objXhr = { open: function() { },
            setRequestHeader: function() { } 
        };

        return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : objXhr;
    },

Now my intellisense works. 现在我的intellisense工作。

You may want to disable JavaScript intellisense in Visual Studio. 您可能希望在Visual Studio中禁用JavaScript intellisense。

When SP1 is installed you can disable JavaScript intellisense. 安装SP1时,您可以禁用JavaScript intellisense。
Go to Tools, Options... 转到工具,选项...

The Options dialog will show up. 将显示“选项”对话框。

Navigate to the following node in the left hand sided panel: 导航到左侧面板中的以下节点:
Text Editor :: JScript :: General 文本编辑器:: JScript :: General

Disable the following options (in the group Statement Completion): 禁用以下选项(在“语句完成”组中):
* Auto list members *自动列表成员
* Parameter information *参数信息

Have you tried increasing the IntelliSense timeout? 您是否尝试过增加IntelliSense超时?

By default, every IntelliSense request is only allowed 15s to execute. 默认情况下,每个IntelliSense请求只允许执行15秒。 This is to prevent IntelliSense from scripts with infinite loops. 这是为了防止IntelliSense来自具有无限循环的脚本。 If you have a large script or slower machine, it may make sense to increase the timeout limit. 如果您有一个大脚本或较慢的机器,增加超时限制可能是有意义的。 The timeout value store within following registry keys (depending on if your are using Express or the full product). 超时值存储在以下注册表项中(取决于您使用的是Express还是完整产品)。 The value is in milliseconds so choose something greater than 15000. 该值以毫秒为单位,因此选择大于15000的值。

HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0\\HTML Editor\\JsFailsafeTimeout HKEY_CURRENT_USER\\Software\\Microsoft\\VWDExpress\\9.0\\HTML Editor\\JsFailsafeTimeout HKEY_CURRENT_USER \\ Software \\ Microsoft \\ VisualStudio \\ 9.0 \\ HTML Editor \\ JsFailsafeTimeout HKEY_CURRENT_USER \\ Software \\ Microsoft \\ VWDExpress \\ 9.0 \\ HTML Editor \\ JsFailsafeTimeout

Does closing and opening the file reset the state? 关闭和打开文件会重置状态吗?

Open the task manager and watch the processes. 打开任务管理器并观察进程。 Do you see a process called "typelibbuilder.exe" get started when you press Ctrl-Shift-J? 当您按Ctrl-Shift-J时,是否看到一个名为“typelibbuilder.exe”的进程启动?

I'm trying to image what sort of problems might require a restart of VS. 我试图想象可能需要重启VS的问题。 The processing of references (to which that message pertains) is done in a new and separate process every time you press Ctrl-Shift-J (unless processing has been disabled in which case you would see a different message). 每次按Ctrl-Shift-J时,都会在一个新的独立进程中处理引用(该消息所属的引用)(除非已禁用处理,在这种情况下您将看到不同的消息)。 It almost sounds like the communication between VS and typelibbuilder or some other necessary component is failing. 这几乎听起来像VS和typelibbuilder之间的通信或其他一些必要的组件失败了。

In SP1, you shouldn't need to reference the "-vsdoc" files directly. 在SP1中,您不需要直接引用“-vsdoc”文件。 If you reference "foo.js" and there is a "foo-vsdoc.js" file next to it, then VS will use the vsdoc version to generate intellisense. 如果您引用“foo.js”并且旁边有一个“foo-vsdoc.js”文件,则VS将使用vsdoc版本生成intellisense。 I doubt that is related to your problem though. 我怀疑这与你的问题有关。

I know this isn't much consolation, but we've drastically improved performance and reliability of Javascript Intellisense in Visual Studio 2010. Beta1 is currently available to MSDN subscribers (although it is beta and there are still some bugs in it). 我知道这并不是什么安慰,但是我们已经大大提高了Visual Studio 2010中Javascript Intellisense的性能和可靠性。目前Beta2可供MSDN订阅者使用(虽然它是beta版,但仍有一些漏洞)。

If you can get reliable repro steps, you could also file a bug report at http://connect.microsoft.com/ . 如果您可以获得可靠的repro步骤,您还可以在http://connect.microsoft.com/上提交错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM