Unable to access 'Build Action' property for .cs files - c#

i got a problem with my site with my app_code files and a lot of question ive read people say you need to change the proprties of the .cs files to Build Action.
by right clicking the .cs files and press proprties.
but...
when i right clicking the files i cant see any option called proprties so i press F4 and it open a proprties window and i just click on the .cs file and still cant see any option i can change somthing to Build Action.
any idea why i cant see this options?
EDIT:
my problem is that when i get in the file proprties i have only 2 options...
thay are called:
1.Full Name
2.Full Path
EDIT2:
here what i see in visual studio 2010 when i try access the protrtie menu/window
http://img338.imageshack.us/img338/2359/blac.png

As Microsoft points out in the article "Web Application Projects versus Web Site Projects":
Web application projects use Visual Studio project files (.csproj or
.vbproj) to keep track of information about the project. Among other
tasks, this makes it possible to specify which files are included in
or excluded from the project, and therefore which files are compiled
during a build.
An answer to a similiar question at CodeProject's forums reveals a hint. Abstract:
[...] Looks like you are working on a web application that is actually a
Website as per Visual Studio. You would need to create a new Web Application
and probably copy over the source files there. [...]
http://www.codeproject.com/Questions/173637/Setting-Build-Action-for-Files-in-App_Data

Have you tried this:

You say you haven't got the option being suggested by other posters.
If this is the case, than it is quite possible that your Visual Studio settings are corrupt; this can give rise to all sorts of odd behaviour.
I would suggest you reset your settings, but please be aware you will lose any custom IDE settings that you've previously applied.
Try this:
In Visual Studio, go to Tools->Import and Export Settings
Choose "Reset All Settings" and click Next
Choose to save your current settings if you wish, or select "no" and then click next.
Choose the collection of settings( he IDE preset) you want, probably "Visual C# Development Settings"
Visual Studio will now revert all settings. Hopefully this will make the Build Action reappear.
[EDIT]
It might be worth trying safe mode too.
To do this, start up a "Visual Studio Command Prompt" from your start menu/programs list in Windows, and start Visual Studio with
devenv.exe /SafeMode
Does this make the options appear?

You can copy the file from Windows Explorer and paste it in the Solution Explorer. It will replace (or do nothing but incorporating it in the proj file) the file and recognize it as C#.

Normally you should see a Property named "Build Action" in the first line of the Property Window. This property should be set to "Compile".

Please select file and right click on it so that you will get following screen
Than click on the Properties you will get following screen
You can find build option in as a first option.

Related

Unable to start program. [VALUE].dll is not a valid Win32 application error in Visual Studio 2017

I have developed an C#, ASP.NET web application in a Windows 7 machine using Visual Studio 2012. Now i had imported the entire project into VS 2017 running on windows 10 machine, and when i try to enter the debugging mode to analyze my code it shows the following error:
I guess the project configurations are conflicting hence it throws this error.
Any suggestions??
The same error happens when Visual Studio solution has selected the wrong Startup Project. The bold project is the designated startup project.
Go to the Solution Explorer > Right click on the correct project and select "Set as StartUp Project" in the context menu.
I also got this error. I ultimately got to know that I was not selecting .sln file.
In VS, you should select .sln file and it automatically loads the complete project structrue is what I learnt.
Selecting .sln file worked for me
These errors are mostly because you are not selecting the .sln or solution file. In your solution explorer tree, double click the solution file and then build and run.
This runs contrary to a users intuition that simply opening a file and running it would work. Consider it a poor user interface. Jet Brains Rider, for instance, does not have this issue.
Change Targeting Platforms with the Configuration Manager and Build the project then try to debug it.I hope this will help you.
Don't export the project folder. upload the .sln file.
It will work.
DLLs cannot be ran/debugged directly. You have to specify host application in the
Configuration Properties>Debugging>Command and then let it load the DLL by itself.
You will most likely need to copy the DLL to the directory searchable by the host application e.g. its root or ./plugins folder.
In the Configuration Properties>Build Events>Post-Build Event>Command Line simply enter something like:
copy "$(TargetPath)" "$(HOST_APP)\plugins"
The Startup Item needs to be a .exe file. It's looking at BusinessLayer.dll because BusinessLayer is currently the Startup Project.
First, build the solution. Then, set the Solution Explorer to folder view and find the .exe in one of you project's /bin folders. Right click on it and set it to the Startup Item.
Finally, click the play button in Visual Studio top bar.
EDIT: Basically the same as Thomas' answer, but I'm pointing out that the "correct project" is the one with the .exe file. I would have commented on his answer, but I have less than 50 rep right now.

vs 2017 intellisense not working C# and XAML

I have a Strange issue that I can't seem to fix, my Intellisense for XAML is no longer showing up and the code behind is only showing the premade Members. The Classes and Methods I have made are not showing up. Also Visual Studios is not recognizing other pages and wont recognize Navigation either.
I have tried going to Tools>Text Editor>C#>Intellisense -Statement completion and checking the boxes Auto list members and Parameter information. I also tried to clear out the cache.
From what I have researched it seems nobody else is having the same problems.
Close all open tabs in the project and quit VS, reopen the solution in VS and right click the XAML file in the Solution Explorer and then select Open With….> Source Code (Text) Editor.
Delete obj folder and clean project
Right click the XAML page>Properties>Build Action>change it to something else and back
Add a new content page under this specific project and check it works or not.
I would like to add that this worked for my .cs files only.
To get the XAML files Intellisense to work try to repeat the above steps on your .cs files or wait for the XAML files to gain Intellisense.
For ReSharper users: I found that having ReSharper's IntelliSense enabled for all languages can break Intellisense unexpectedly (especially for XAML files). Here's how I was able to fix the same problem that the asker had in Visual Studio 2017 with ReSharper installed:
In Visual Studio, go to the ReSharper menu and click on Options.
On the left side go to Environment > IntelliSense > General.
Select the Custom IntelliSense radio button.
Change any languages that have broken IntelliSense to Visual Studio (like XAML).
Click the Save button.
Just Exclude and Include Xaml Pages and It works again.
I solve that by changing the default editor in visual studio :
In Visual : File > Open
In the open file box : Select a .xaml file (don't open it)
Select "Open with" in the button arrow
Select "Source Code (Text) Editor and Set as Default
Click OK
I tried most of the above without much luck, but noticed if I created a new page, then intellisense worked as expected. For the properties section of the xaml file I noticed that the new page had a Custom Tool assigned (MSBuild:UpdateDesignTimeXaml) do I tried to cut-and-paste this into the existing forms without luck.
Looking at the .cs page for the new page that worked I notice that there is some extra info above the partial class [XamlCompilation(XamlCompilationOptions.Compile)] so I added this along with a using Xamarin.Forms.Xaml statement.
Finally I went back to the xaml properties page and selected Reset to Default for the Custom tool. Voila, for me everything started behaving itself.
Please add the following Nuget Package from Nuget Console.
Install-Package MobileEssentials.FormsIntellisense -Version 0.1.1-pre
You can download the latest update from the following link.
https://www.nuget.org/packages/MobileEssentials.FormsIntellisense/0.1.1-pre
After installing the package please restart the project and wait for sometime and check it.
Just delete .vs directory. this directory is hidden. so
Just Exclude and Include Xaml Pages worked for me too. The difference in .csproj file was:
MSBuild:Compile
now:
XamlIntelliSenseFileGenerator
I could fix the issue in VS2019 by launching the VS installer to modify it, un-check and check the workload ‘.NET desktop development’ to re-install it.

Checkout A Project With Git And Visual Studio

I recently started using Git with Visual Studio 2015 and I'm trying to modify the properties of an installer project. The issue is that it won't let me because the project isn't checked out and I don't see an option to check out the project with Git through Visual Studio. The only place I even see the mention of the words 'Check Out' is under branches and it's grayed out.
I'm having the same problem in VS2015. It seems to be an issue with the Installer Project extension. For some reason Visual Studio doesn't detect when you attempt to change the Setup Project file (with YourProject.vdproj), and doesn't automatically unlock it for you. I had the same problem with TFS, but in that case all you had to do is manually unlock the file, by right clicking on it. I've just migrated to Git, and the problem is still there, but now you can't unlock the file by right-clicking on it (since there is no explicit check-out in git).
I'm still looking into the problem, but the only solution I've come up with now, is making a quick manual edit of YourProject.vdproj in Notepad. Visual Studio WILL recognize that edit, and unlock the file for you. After that you can continue to use IDE to make changes to the Installer project.
Unfortunately, the problem comes back once you check in your changes, and try to modify the file again. You will once more have to manually edit it to force Visual Studio to unlock it for you.
EDIT: After spending a few hours on this, I finally came up with a proper fix, which I verified works on a few in-house projects. Here are the steps:
Open your solution file in notepad, and delete the following section: GlobalSection(TeamFoundationVersionControl)
Open the solution containing locked Setup Project in Visual Studio.
Go to Tools > Options > Source Control > Plug-in Selection, and pick 'None' from the dropdown.
Click Yes to the dialog that warns you the project will be closed.
Open the solution again, you will be prompted to permanently remove
source control bindings from the projects. Click Yes to that.
You can now go back to Tools > Options > Source Control > Plug-in
Selection and pick Git again.
At this point the problem is fixed, and you will be able to modify
your Setup Project without any issues.
I found that removing bindings is clearing the values of the following tags from the project files:
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
Apparently SAK stands for 'Should Already Know'.
Here is a workaround I found,
Mark the project installer in the Solution explorer, And click "Save" (not save all).
For me it did the trick.
If it's still didn't help try to reopen VS and try the method again.
Cheers!
Open a command line, go to where you need to check it out, then issue the git checkout command? http://git-scm.com/docs/git-checkout
Like Eternal21 I encountered this problem when trying to modify an Installer project, this was in a VS2013 (rather than VS2015) project though and I could not see a GlobalSection(TeamFoundationVersionControl) in the solution file. However the following steps worked;
Go to Tools > Options > Source Control > Plug-in Selection, and pick 'None' from the dropdown.
Make the change required to the Installer project
Go back to Tools > Options > Source Control > Plug-in Selection and select Git again.
(and the Solution did not ask to be closed).
You need to create a new empty repo on your Git server first, then clone it to a folder on your local computer.
After that you will be able to add your project and check it in by adding it to the local folder.
I was able to work around this problem by simply editing the vdproj file (setup project file) manually in Notepad++ (you can use any text editor), making some temporary changes into it (type a character and backspace) and saving the file. This effectively checks out the project from GIT. Now you can come back to Visual Studio and make whatever changes you want.
I was able to use dotNETs suggestions and edit the vdproj file. Simply adding a character and removing didn't work, but making an actual edit did. Doing so triggered the check out for GIT. In my case I was attempting to change one of the Detected Dependencies exclude property to false and was able to do so while editing the vdproj file. Once I saved it then reopened Visual Studio the check was displayed on my installer and the change was already applied. I was able to make additional changes while checked out.
Once finished and I checked it in, I could no longer edit and needed to manually edit the file again to check out.

Visual Studio compiles fine, but it still shows red lines

I am using Visual Studio 2012 and it was working all fine until I started observing some funny behavior. When I open my code it shows red Underlines which we usually see when there is an error in our code. Surprisingly, the code compiles all fine. I have made following observations that are not normal at all.
Red underlines in the code
While cleaning or building the solution no error.
Red underlines go away for some time after I build/clean the solution, but they come back eventually.
Because of this, my IntelliSense stopped working.
I can not right click on any component and go to its definition.
Any ideas?
Visual Studio 2017, Visual Studio 2019, Visual Studio 2022:
Closing Visual Studio and removing the .vs folder located in the solution directory worked for my C# projects.
This folder has a hidden attribute. You may need to change View settings to show hidden files in File Explorer.
Delete the contents of the temporary ASP.NET folder and then rebuild. It'll either be in your user folder (for IIS Express - \AppData\Local\Temp\Temporary ASP.NET Files) or the Windows directory (for IIS - C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)
Paths are off the top of my head and may not be correct
For me, this issue got fixed when I unloaded and reloaded the project again.
I had this issue and it was related to ReSharper.
Solution steps for me:
Disable ReSharper
VisualStudio\Tools\Options\ReSharper Ultimate\General\Suspend Now
Build Solution
(Ctrl + Shift + B)
Re-enable ReSharper
VisualStudio\Tools\Options\ReSharper Ultimate\General\Resume Now
Just had this problem while working with a solution created in Visual Studio 2012 but running in 2013. I closed Visual Studio, deleted all \bin and \obj directories and the problem was gone.
I had this problem after resolving some conflicts from Subversion (SVN). The solution has several projects in it and I resolved some conflicts in a few different projects. I did a menu Build → Clean Solution followed by a men Build → Rebuild Solution and everything was good again.
Do you have any plugins installed, like ReSharper? I had an issues with a bad plugin.
Try running Visual Studio in safe mode, to prevent plugins from running.
devenv /Safemode
If you are using ReSharper like me, you may delete ReSharper cache following by this link: Configure Caches
To specify the location for caches:
Open the Environment → General page of ReSharper options.
Use the Save solution caches in to select the location for cache files:
User local settings folder to store them in the following directory: %LOCALAPPDATA%\JetBrains\Transient
4.System TEMP folder to store them in the following directory: %TEMP%\ReSharperCache
Solution folder to store them in the root folder of the current solution
Custom folder to choose a custom location for ReSharper cache files.
Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see managing and sharing ReSharper settings.
Reopen your solution for the changes to take effect.
What works for me is deleting the IntelliSense indexfile.
The IntelliSense-file is in the same directory as you solution.
It's filename is SolutionName.sdf
Just delete this file, open you solution again, and IntelliSense will start rebuilding its indexfile. After that the problem will be gone.
In Visual Studio 2013 I solved this problem by deleting all of my obj and bin folders across all projects. The issue was probably due to solution configurations that I had deleted, but I hadn't been cleaned up properly, as doing a menu Build → Clean Solution doesn't remove the old outputs from the obj and bin folders.
This worked for me in Visual Studio Enterprise 2017:
Navigate to Tools > Options > Text Editor > JavaSCript/TypeScript > Linting > General
deselect "Enable ESLint"
I've run into this as well and was able to return Visual Studio to its normal state by doing the following -
Identify the project where the red lined code comes from
Remove the "red line" project from the references where it is being used (ProjectName\References - right click, add references, and uncheck the "red line" project)
Build (you should get errors now)
Readd the project reference that was just removed
Build again
The red lines should be removed and the project should build!
Steps that work
Open the solution and do a rebuild all
Close the solution
Open solution and do a clean
Close solution
Open solution and do a rebuild all
Close and then open the solution. It should be good. This works for me every time
Be careful deleting some of these settings files as you will lose saved debug settings, etc. And it may do more damage than you realize.
I have found recently it is easy to solve this by switching from Debug to Release in the dropdown to left of the Play Button. Then switching back from Release to Debug.
I had the same problem with lots of red lines in several *cpp source files. Though the code compiled perfectly. None of the other solutions worked for me.
Changing the order of #include lines of a *.cpp-file could make the red lines disappear - and reappear with the restored order.
Then I noticed a header file was included twice in a single *.cpp file. I removed the second one and - everything was fine.
Including a header file twice in the same *.cpp file seems to be no problem to the compiler but to the IntelliSense part.
Simply refresh the project/solution. It will get resolved.
I ran into this problem with the latest Visual Studio 2017.
Also the debug version of my program was running painfully slow.
I deleted the Solution file .sln and created a new one.
I had a similar problem when I was seeing lot of red squiggles in a couple of files. I tried all answers proposed previously, but nothing seemed to work.
The moment I started browsing through the classes, structures in other files for which complaining files had references, the problem disappeared. It seemed IntelliSense was not able to resolve dependencies on its own for some reason.
For me, I had at one time enabled fusion logging to debug some assembly dependency errors (fuslogvw from a CMD prompt). That was months ago and I had been experiencing much slower build times (5-7 minutes) since then.
I had also forgotten entirely that I had left them enabled. These logs were my bottleneck and disabling them has made iterating much faster.
In my case with Visual Studio 2017, I have many "red lines" shown below all symbols defined in a third-party library, but my project can actually build without problems. I have tried all suggested solutions (like delete the .VS folder, restart Visual Studio, etc.), but none of them working.
Finally, I fixed it and this is how: I open my application project's property page, then go to C/C++ → General → Additional Include Directories, which is the place I put all needed third-party library header paths.
I delete all the path (but save them somewhere), click "Ok" to confirm. Then I come back to the same setting, paste those paths back, click "Ok" to confirm, and then all those "red lines" disappear.
I have VS2019 with ReSharper, and ran into this issue.
What worked for me was:
Go to the ReSharper >> Options menu
Go to the General tab (should be the default)
Press the "Clear caches" button
Close all instances of Visual Studio (2019)
Restart Visual Studio
Using VS2022 without Resharper when this problem occurred, tried several things, this did help me in the end:
Close Visual Studio
Delete folder .vs in the Solution folder
Go to folder %USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\
Delete all folders whose names start with 17.
Reopen Visual Studio
More specific subfolders could exist that might be enough to delete, but I had no issues after deleting all of it. AFAIK these only contains user session data, temporary files and/or cache files that can be downloaded again or recreated as needed.
Found this solution:
Close Visual Studio (ensure devenv.exe is not present in the Task Manager).
Delete the %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\xx\ComponentModelCache directory.
Restart Visual Studio.
I have had this problem for months and have finally fixed it. Closing Visual Studio and removing the .vs folder located in the solution directory did not work for me.
There was an assemblyIdentity tag in the web.config file which was referencing a library that was not in my references folder. I removed this tag, cleaned, closed and reopened, and the problem was fixed.
Check each of the assemblyIdentity tags in your web.config file and check them against the references folder in solution explorer
Remove any assemblyIdentity tags, including the parent dependentAssembly tag for any which aren't listed in your references folder.
Clean the solution
Close and reopen the solution
Deleting .vs folder did the trick for me.
for me this works:-
Open the Command Palette ctrl+⇧+p
Then type: reload Window.
Deleting all the folders which start with "asp.xxx" worked for me. You can reach these folders by:
(C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)
Hover over the word that has the red underline squibble. A mini dialog box will appear. Click on 'Quick fix' and then click on 'Disable error squibble'.

Visual Studio. Code changes don't do anything

Any changes I make to my code aren't doing anything. I've even tried putting lines in that I know will crash my program, and nothing. It just keep running the old version. It's even loading old versions of files I've edited and saved.
There a 3 projects in my solution. 2 are pure C#. 1 is a WinForms application.
It sometimes happens that some files "are being used by another process".
Close your solution and delete all "bin" and "obj" subfolders of all your projects that are included in the solution.
Then open your solution again, execute "Clean solution" and build it again.
Check this setting in Tools/Options, then under Projects and Solutions>Build and Run.
On Run, when build or deployment errors occur:
My personal preference is for this value to be 'Do not launch'. It will prevent Visual Studio from launching the "last successful build".
Try Ctrl+Shift+B. This will build your solution (not just a particular project). Other environments might build when you save but this needs to be explicit in Visual Studio.
Had issue with saving code changes on VS2017 (mac) Version 7.3 Preview (7.3 build 740)
Only way to get file changes to save was to do File > Save All
Doing File>Save would act like the file saved. But, when I opened the file again and no changes were saved.
Ok, you need to add more detail, but you may want to have a look at this answer:
How to enable/disable compile errors warning in Visual Studio
delete Published DLL From Bin
file names -
projectName.ddl
projectName.pdb
delete these two files and run project
I had the same problem (Visual studio 2015 is not noticing my modifications in C# XAML files).
Problem solved by deleting 2 'debug' subfolders. One in the bin folder and one in the obj folder.
I met the same problem. the code changes is not saved.(you can see from the edit it is in Yellow color. e.g. indicating changes). SAVE and BUILD will not let it save the changes. i have to wait sometime, then it could possibly save success..
Deleting the whole project and the corresponding folder from local and check out the solution again. This worked for me=> VS2017
I solved the problem like this:
1. I closed the program
2. I opened the folder that contains the file (.csproj) and opened it with Visual Studio.
Next, I chose the folder to run the command as in the image
Had the same problem. Turns out I had moved a project folder. Even when opening the solution from the moved folder and editing and saving this source code, VS 2019 was building and running a different instance of the program with the same name. Go to File-> Save yourproject.cs as..and manually walk back through the directory structure to find the instance VS is actually running. Hope this helps.
also check another option in Tools>Build and Run>Only build startup project & dependencies if you have more than 1 nested dependency, especially when using Prism or any other reflection-based frameworks that prevent "dependency detection". Also, make sure you're in the editor when using shortcuts like Ctrl+S (Save) or Ctrl+Shift+S (Save all)
Go to this location:
C:\Users\<your_system>\AppData\Local\Microsoft\VisualStudio\<studio_version>
Then remove all files and start Visual Studio.
this was the error , no changes made after build.

Categories

Resources