I am building a C# adding for Excel. In order to debug it, I need to launch Excel.exe with a command line argument containing the Debug or Release path to the addin.
For example:
Start External Program: C:\Program Files\Microsoft Office\Office15\EXCEL.EXE
Command line argument "C:\Dev\Project1\Project1\bin\Debug\Project1-AddIn64.xll"
However, I would like to replace "C:\Dev\Project1\Project1\bin\Debug" with an equivalent of $(SolutionDir) for C++ projects in VS. Is there a way to do this ? If it is not doable, is there a way to get around this ?
EDIT: please support me and get this added in VS by voting up the following idea: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6350738-support-for-macros-in-debugging-command-line-argum
Indeed, the macros cannot be used in the Start Options | Command line arguments
I see two solutions:
As the current folder is set to the $(TargetDir) when you Start an application you could refer to the solution folder like this: ..\..\..\ if the External program accepts a relative path. (I am not quite sure why you would ever want to refer to the solution folder, referring to the output/target folder makes more sense to me)
In the Post Build event (unregister) and register the component the way the component should be registered when deploying it (a proper setup). This way you only have to refer to Excel in the Start Action. This also immediately adds the benefit of testing a scenario that is more similar to production.
It's not exactly a fix, but this may help some people. If you create your project from the project template "Visual C#/.NET Core/Console App" instead of "Visual C#/Windows/Console App", this feature is supported. When I put "$(SolutionDir)" in the Application Arguments field on the Debug tab of the Project Properties window, it is expanded at run time. Note that you will need Visual Studio 2015 Update 3 or later.
I guess you could make use of post-build event to read in your file. #HansPassant explained it in VS2010 - Project Macro Variables in Start Options Command Line Arguments.
A short quote:
A possible workaround is a post-build event that writes a file that you read in your program. Like echo $(ProjectName) > "$(TargetDir)cmdargs.txt
You could substitute cmdargs.txt to appropriate file you want.
You CAN use the macros in the Command fields. I used procmon.exe to see what VS was looking for and indeed i could use $(SolutionDir)\..\Debug\thetoolname.exe as my solution was not in the root.
Im using VS2019 so AFAIK it is supported from this version but it most likely is supported in lower versions. Just use procmon to check the path that VS is attempting to resolve.
I have Visual Studio 2013 with no plugins or anything fancy. Whenever I'm coding, every so often (maybe once every half hour) intellisense randomly stops completing my sentences or popping up at all when I press Ctrl+Space.
I have tried Tools->Import and export settings->Reset all settings but it did not help. The issue came right back.
The only thing that solves it for me now is to close VS and reopen it. But as you can imagine, this is extremely frustrating.
I was having the same problem and this seemed to work for me.
http://omegacoder.com/?p=1008
Basically, go to Tools >> Options >> Text Editor >> All Languages >> General and make sure that both Auto list members and Parameter information are checked (not the half-checked/square state).
This is still happening in VS2013 update 4 (I have a WPF project using C#).
This was relatively easy to fix by closing then reopening the file not the whole project.
For me, Unloading and Reloading a project fixes MVC cshtml intellisense. Right-click project, click Unload. Right click grayed out project, click Reload.
Just to be clear, this problem only happens to me when in C# MVC views, only when checked into TFS.
I have also submitted this as a bug to Microsoft, see https://connect.microsoft.com/VisualStudio/feedback/details/932855/vs-2013-c-default-mvc-template-breaks-upon-checkin-to-tfs-2010
Looks like my issue cleared up after deleting the settings folder from my previous VS2010 installation. I followed the instructions here (Also applies to VS2013): http://www.haneycodes.net/visual-studio-2012-intellisense-not-working-solved/
In case URL breaks:
Open the start menu and type “%AppData%” and press enter to get to your Application Data Folder.
Either you were automatically placed in the “Roaming” folder or you weren’t. If you weren’t, go to the “Roaming” folder.
Open the “Microsoft” folder.
Open the “VisualStudio” folder.
Here you’ll see a folder titled “11.0” (the VS 2012 folder) and probably also “10.0” (the VS 2010 folder).
DELETE (or rename) the “10.0” folder. Note that you can now kiss your Visual Studio 2010 settings and preferences goodbye (your projects will be safe and sound).
DELETE (or rename) all other folders that are not the “11.0” folder, assuming you used to have Visual Studio 2008 or whatever.
Now restart Visual Studio 2012 and you should be good to go!
try to delete the .suo file of your solution. It worked well for me.
The first thing I should mention is that this hasn't happened since I've upgraded my RAM. I was at 4GB when this was happening. Often had multiple instances open as well as SQL Server.
I'm finding this seems to happen when I copy/paste controls on a page. Another side affect of this is that the designer.(cs/vb/xx) file is not updated right away and I don't have access to those controls in code behind.
I've tried a handful of things and here's a summary of what I've found so far:
If only 1 file/window appears to be affected, close/reopen that file.
If that doesn't work... in Visual Studio:
Click Tools->Options->Text Editor->All Languages->General
Uncheck "Auto list members"
Uncheck "Parameter information"
Check "Auto list members" (yes, the one you just unchecked)
Check "Parameter information" (again, the one you just unchecked)
Click OK
If this doesn't work, here's a few more steps to try:
If still not working, close all windows and reopen
If still not working, close/reopen solution
If still not working, restart VS.
(I haven't yet figured out why more drastic steps are required in some cases.)
For C++ projects:
MSDN has a few things to try: MSDN suggestions
The corrupt .ncb file seems most likely. Note that in VS2013 and later, it is the .sdf file, which can be found in the root folder. Try searching for filename:*.sdf.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Notes:
Tested in VS 2013/2015
Logging possible causes:
Copy/pasting controls in a source page. I found that my designer.vb file didn't update from this, either.
Copy/pasting code from another page that caused an error because the code copied referred to a control that wasn't on the page I was pasting to.
C++ project has corrupt .ncb file
Like cacau says, you must first do a clean of the entire solution. Then restart VS rebuild the entire solution.
This sometimes happens when you are using Entity Framework or WCF services (Or the combination)
VS generates a lot of files then that contain code (the service reference for example). When you regenerate that code (And for example you are running a web project) sometimes you forget to stop the site. Then VS can't overwrite every file. Resulting in a global intellisense failure.
For me, the problem happens when I have two instances of same solution opened. On one of them I'm running Tests, while on the other I am making tweaks to code. Intellisense will quit working on me usually after I've run some tests and stopped the debug session manually.
The solution for me is to close all VS windows and reopen...
Did you try a clean build on your project?
VS might have become confused with some of its generated files..
None of the solutions in this thread worked for me.
what worked was that I deleted everything in the packages folder. when I rebuilt the solution, nuget got the latest versions of all the folders I deleted, and intellisense started working fine.
If I am not mistaken, the problem initially was caused by the contents of the "Microsoft.Net.Compilers.1.0.0" folder, but I dont know why.
If you have this problem in one file, make sure that this file is included in your project. Right Click the file, Select Include In Project. If the file is not included in your project, VS will treat it as a normal text file.
I followed the instructions given in response to the question : Visual Studio 2012 - Intellisense sometimes disappearing / broken (thanks to SajjadHashmi and others). I've copied the steps I followed (which worked for me) here in an attempt to be helpful.
1: Close all the tabs and open your file again. (Thanks to russds)
2: Clean the Build > Close the Solution > Restart Visual Studio > Open the Solution again
Further steps are listed if you follow the above link but some seem to no longer apply to Visual Studio 2013 (e.g. refresh Local Cache for intellisense).
I know that these steps involve restarted Visual Studio (which you are explicitly trying to avoid) but for those who find your question (such as me) a potential solution might be useful.
In case anyone else fell into the black hole I did ... I too suffered from this issue but NONE of the above solutions worked for me. Eventually I figured out that somehow the opening <body> tag had been deleted from my .Master page and that was causing all my .aspx pages to lose 95% of the Intellisense code hinting. Once I added the missing <body> back to my .Master page, the Intellisense finally started working in my .aspx pages again! Hope this helps someone ... just cost me 1.5 hours!
Sometimes none of suggestions here works - at least that happened to me.
But don't rush with configuration resetting, cleaning up visual studio configuration files and so on. If clean/re-build + vs restart does not work - problem might be in code itself.
In my case (vs2013) I had C++ class exposed in .h like this:
class MyClass: ...
{
....
DLL_EXPORT returnArgs function(InParameters)
}
where DLL_EXPORT is defined as :
#define DLL_EXPORT __declspec(dllexport)
Same function in .cpp:
returnArgs MyClass::function(InParameters)
{
}
vs2013 was refusing to jump between function definition / implementation.
Reason seemed to be DLL_EXPORT macro - I've written function like this:
DLL_EXPORT returnArgs MyClass::function(InParameters)
{
}
After that intellisense started to work again.
It's possible also to remove that define or wipe it out - according to visual studio documentation __INTELLISENSE__ - but that define did not work for me for some reason. Code snipet like this:
#ifdef __INTELLISENSE__
#define DLL_EXPORT
#else
#define DLL_EXPORT __declspec(dllexport)
#endif
Please comment if you understand why this does not work.
In vs2015 this issue seems to be fixed, but there are other problems with vs2015.
None of these things worked for me. After lot of struggle I found why it was not working for me. I always had multiple solutions open in my machine. For suppose, One solution is for front-end layer and another solution is for back-end layer.
When it hits breakpoint kept in backend service layer intellisense was not showing up. After I closed all other solutions and rebuild the solution where I wanted to debug, everything worked fine.
There could be other reasons, but this worked for me and wanted to let this community know and it may help someone.
EDIT: Few times "delete all breakpoints" and adding again worked.
I had the same problem and in my case it was the same file being open twice. For example I have dev\include\myfile.h AND dev\include\myfile.h\ (note the backslash, making this a unique string).
This happens when I use F12 to find a symbol in an include file, but also have the original .h file open already; Visual Studio opens up a duplicate file, which is really the same file.
When saving either of the two instances, the changed file date will be noticed and I get a popup asking whether I want to reload the other instance. More problematic seems that it also confuses IntelliSense. I just tried closing all duplicate instanced files, and IntelliSense started working again without restarting or reloading anything.
I tried to fix my problem by solution VS2013 Intellisense constantly stops working
But it did not work for me.
Solution that worked for me is off/on Auto list members
Go to Tools > Options > Text Editor > General
I want to add a small piece of information such as a software package version I have on my machine to my C# executable.
I want this info pulled on the fly during every build of my program. The info is just 1 line in a text file saved somewhere on C:\
The info needs to be accessible to my program, when I click a button within it, it should display that line of text it grabbed during the build.
Perhaps this could be accomplished by putting the info into a custom environment variable, which gets propagated during a build by adding a before build target. Not sure how to do that, if its even possible. Im using VS2008.
Please share your ideas!
VStudio has the option of performing pre-build steps. In our build, we have a batch file that executes tools that in turn generate a small file of C# which is then built by the build process. It's not very elegant, but has the benefit of simplicity and it works.
If you are the only person to be building this (or everyone building it has this text file in the same location), you could add your text file to your project as a linked item.
This way the file would be included with your project without creating a copy so any updates to it would be propagated to your project.
Right-click the project in solution explorer
Add->Existing Item...
Once you have navigated to your text file, click the down arrow icon at the right edge of the add button and select "Add as Link"
These steps are copied from this answer to a different question. That question was dealing with VS2010, but this should work in VS2008 just the same.
I have a program that cleans up the names of files within a folder. It removes the spaces and illegal characters and replaces them.
This currently works by debugging the program in Visual Studio and finding the folder to run the clean up on using the folderBrowser. I think it would be really cool if I could just find the folder in my Documents without running Visual Studio that I want to clean up, and then right click and select the 'file clean up' program from the usual list (notepad, open, sent etc).
I am not asking anyone to build this for me, I just would like to be pointed in the right direction into how this could be done.
You will need to implement windows shell extension (sample)
I have a project in c# which uses bindings to use some c++ code. The c++ code consists of multiple DLL's which are compiled using a makefile. Currently I'm trying to run the makefile using a pre build event which calls nmake. However to get it to find nmake I need to have a line in it like the following:
"$(DevEnvDir)..\..\VC\vcvarsall.bat"
Also, even with that line present, nmake doesn't produce any output at all in the output window. Neither does it throw any errors. I tried redirecting the output to a file and it doesn't write anything. I have reproduced all steps in my pre build event in a normal shell and it works fine. I figure I must be missing something. Why doesn't Visual Studio give me a Visual Studio shell for my pre build event? Is there a better way to run this makefile? If not, has anyone got any ideas as to why nmake isn't producing any output?
EDIT: D'oh! nmake wasn't running as I forgot to add 'call' to the start of the line, i.e:
call "$(DevEnvDir)..\..\VC\vcvarsall.bat"
I often build non VS-project (sometimes with nmake, sometimes with other build tools) as a part of a larger solution build.
I tend to make a simple batch file, which sets up the environment and then runs the make.
I call the batch file from a build event (often post-build on my stuff) - usually with a CD on the front:
cd ..\.. && armbuild
Never (that I can remember, anyway) had any problem with the output appearing in the console window.