Определения типов Office.js
Вам необходимо предоставить Visual Studio определения типов Office.js. Для этого можно сделать следующее:
Создать локальную копию файлов Office.js в папке вашего решения под названием \Office\1\ . Эта локальная копия будет добавлена в шаблоны надстройки Office в Visual Studio во время создания проекта надстройки.
Использовать интернет-версию Office.js, добавив файл tsconfig.json в корневой каталог проекта веб-приложения в решении надстройки. Этот файл должен иметь указанное ниже содержимое.
Основной метод — добавить перед переменной (параметром и т. п.) комментарий с указанием типа данных. Это позволит IntelliSense в Visual Studio определять участников. Примеры.
Fixing Intellisense and Go To Definition in Visual Studio 2019
I had a set of very strange problems after upgrading to Visual Studio 2019 early this week, and they were significantly hampering my ability to get work done.
- didn’t work for a great many classes, methods, and properties.
- Intellisense was straight-up missing in multiple places.
I hadn’t realized how much I relied on those two features of Visual Studio until I could no longer use them. It was like suddenly missing a finger, or being unable to find my phone: part of myself was gone.
"I can hear it buzzing. Where the $#^! is it?!" Photo by André François McKenzie / Unsplash
I went off to Google the problem and found nothing that helped me. So, when I eventually did find the solution that worked for me, it occurred to me that I cannot be the only one with this problem. Hence, this post.
Here’s how I fixed my missing Intellisense and nonfunctional Go To Definition in Visual Studio 2019.
(If you’re just looking for the solution, jump to the Summary section at the bottom)
Tracking the Problem
Our project is an ASP.NET Framework 4.5.2 MVC solution, with lots of other tech thrown in (e.g. Entity Framework). As I mentioned at the time, the Intellisense and definitions were not missing for all of my classes, methods, etc., just for a majority of them. For example, in my controllers I could not use Go To Definition on the ASP.NET MVC Controller class, nor the attribute HttpGet, nor any of our custom classes for this project. But I could use it on certain common extensions, such as ToString or ToList.
It took me a while to work this out, but I eventually determined that what I was actually missing was all of ASP.NET MVC and Entity Framework. With that commonality in mind, I started poking around the solution, which is when I discovered this:
All of my project references were in error! Even ones that should exist on my system, like System.Data.
Which is stupid. I can use this project perfectly fine in VS 2017, so why was VS 2019 giving me such problems? And, more importantly, what was I going to do about it?
Potential Solution #1: Delete the .vs File
A bit of googling lead me to this blog post by Rick Strahl which suggested that I should delete the hidden .vs folder at the root of my solution. When I did so and opened Visual Studio again, VS recreated this folder. But, unfortunately, it didn’t fix the issues I was having with Intellisense and Go To Definition.
It was at this point that something occurred to me: all of the things which I could not get Intellisense for (MVC and EF) were, in fact, NuGet packages. I wondered if this had something to do with NuGet, and, it turns out, it does!
Potential Solution #2: Restore NuGet Packages
There’s a right-click option on .sln files called "Restore NuGet Packages". This was the first thing I attempted to do while trying to fix this problem. Unfortunately, it didn’t help, because all I got was this:
"All packages are already installed and there is nothing to restore." Which is not helpful in the least.
Potential Solution #3: Use the NuGet UI
The next thing I could think to do was use the NuGet UI within Visual Studio to reinstall all the packages. Problem is, there is approximately (counts on fingers) 57 jillion packages on this solution. Refreshing them using the UI would take a lot of time.
Clearly I was not going to do this. I needed something a bit more. forceful. Which is when I stumbled upon the actual, final solution that restored Intellisense and fixed Go To Definition.
Actual Solution: Delete Local NuGet Packages
. I deleted my local copy of this solution’s NuGet packages.
At the root of our solution there is a packages folder. I deleted the entire contents of this folder. Upon reopening Visual Studio, Intellisense and Go To Definition were restored to full working order.
Another stupid problem solved!
If I’m being completely honest, I do not know exactly why this works. After all, Visual Studio showed errors on references which should exist on my local machine, not in NuGet packages. But at this point, I don’t particularly care why it works, I’m just glad it does.
It turned out the issue was related to NuGet; what I needed to do was delete the contents of the packages folder. For completeness’s sake, here’s the steps to do what I did.
- Close all instances of Visual Studio 2019.
- Delete the contents of the packages folder at the root of your solution on your local machine.
- Open Visual Studio 2019 again.
This final solution worked for me. I am including the potential solutions in this post in the hopes that one of them (actual or potential) works for you, dear reader. Let me know if you have any other solutions in the comments!
Как включить intellisense в visual studio 2019
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
I’m having issues with one specific project in VS2019. After upgrading from VS2017, I got the solution from the TFS.
Everything was working fine until I modified a file of this project. Intellisense stopped working.
It should be something related to this project file because if I modify other files in other projects from the same solution it keeps working fine.
What can I do to try to fix it?
Welcome to the MSDN forum,
“ Everything was working fine until I modified a file of this project. Intellisense stopped working. ” What and how did file you modify? Could share us the specific steps and info? Did you try to rebuild your project after modifying done?
I am guessing, Intellisense doesn’t know what to do or recognize this file, please unload and reload it.
If not, please have a try with the following steps to clean caches of your project: