How to disable fxcop - visual-studio-2010

I have a project created in visual studios 2010 pro, now opening it ultimate I am getting 100s of errors i belive because of fx cop.
How do I just simply turn it off.
I have right clicked and gone to code analysis, what setting do I have my website on?
EDIT:
the reason i need to turn it off because i get this main error:
Error 1 CA0060 : The indirectly-referenced assembly 'Newtonsoft.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. This assembly was referenced by: C:\CMS\packages\DataTablePager\DataTablePager.dll. Application

Right click on your project node in Solution Explorer, choose Properties.
There is a Code Analysis tab near the bottom. Click that and uncheck "Enable Code Analysis on Build".
Alternatively, you could right click on that error, and choose "Suppress". This will allow you to suppress that error from being generated.

Add <RunCodeAnalysis>false</RunCodeAnalysis> to your .csproj files (I slapped it in the first <PropertyGroup> I could find) and stop using Analyze > Run Code Analysis because that still runs the old FxCop.
If you use the old ASP.NET (not Core), right click on a project and click Unload project before you can edit the .csproj.
Source: https://learn.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers-faq?view=vs-2019

Related

Visual Studio 2013 Set as start up project does not change the project

I have several projects in the solution. When I set the "Set as start up project" (In VS 2013) to the Console application project and when I hit F5, it sets the start up project to a particular class library project (Class Library 1). I cannot change the start up project from "Class Library 1" to anything else. I tried to change the start up project by right clicking the project as well as right clicking the solution and then set the start up project from there.
When I set the start up project as the "Console App1" project, it indicates that it has been selected properly (bold the project name). But once I hit F5, it tries to execute "Class Library 1" (bold the Class Library project) and gives an error (A project with Output Type of Class Library cannot be started directly).
I tried to delete the .suo file and open up the solution, still I am getting the issue.
Where is the start up project details are stored? Could not find any clue inside the sln file as well. Any ideas?
Ok, found the issue. Forgot to mention that I am using Resharper. There was a resharper "dotSettings" file (.sln.DotSettings.user) in the solution directory which has the following entry,
<s:String
x:Key="/Default/RunConfigs/Config/=9DF93B60D662E841A397F5FDE870C414/Name/#EntryValue">Class Library 1</s:String>
Solution is to delete this file. (Changing this entry did not solve the issue.)

Visual Studio Redeploy feature for BizTalk solution does not work

My BizTalk solution has 10 BizTalk projects that are referenced between each other.
In each project's properties I have set redeploy feature to 'true' (it's by default).
But when I try to redeploy the whole solution from VS 2012, I get following errors for some projects in solution:
Error 201 Failed to add resource(s). Change requests failed for some
resources. BizTalkAssemblyResourceManager failed to complete end type
change request. Cannot update assembly "Project1, Version=1.0.0.0,
Culture=neutral" because it is used by assemblies which are not in the
set of assemblies to update. To update the assembly, remove the
following assemblies: Project2, Version=1.0.0.0, Culture=neutral
Project3, Version=1.0.0.0, Culture=neutral Project4, Version=1.0.0.0,
Culture=neutral Project5, Version=1.0.0.0, Culture=neutral Project6,
Version=1.0.0.0, Culture=neutral
As I read from this article:
http://blog.codit.eu/post/2013/07/30/Redeployment-notes-of-a-BizTalk-solution-from-Visual-studio.aspx
In the process of deploying a BizTalk assembly, you first needed to
manually stop, unenlist, and unbind artifacts contained in the
assembly in BizTalk Server and then remove the assembly from the
BizTalk Management (configuration) database before deployment. Visual
Studio will handle all those steps for you with this option Redeploy.
What could be the reason of my problem and possible solution?
Please check if you use subfolders in your solution.
I suggest to create new (additional) solution just for deployment purpose where you should avoid to use any solution subfolders
Andrei
You can try deleting the temp binding files at: C:\Users\%username%\AppData\Roaming\Microsoft\BizTalk Server\Deployment\BindingFiles
Then try again.
Check that one of the assemblies hasn't gone into the Default Application rather than the application you are deploying too. If you find one in the wrong place you can right click it and select Move to Application. (The other option is to remove it, but then quite often you have to remove all the dependent ones as well).
Check each project that the Application is set.
Then re-deploy.
This happens quite often, especially if you just got a project down from source control, as the Application is saved in the user file rather than the project file.
Edit: Also check your solution setting to make sure all projects have deploy ticked.
Check in the configuration manager for solution if any project is not marked for deployment. Right click on solution then select Configuration Manager and make sure all projects are selected for deploy,
Apparently there is some problem with BizTalk 2016 party export/import that prohibits re-import of bindings during deploy from Visual Studio.
My workaround is to export bindings manually before deploy, and manually import bindings after "successful" deploy (cited from the deploy log in visual studio ;).
Other reference:
https://social.msdn.microsoft.com/Forums/en-US/c49758c0-0465-4c13-97a3-300c05d00d3a/biztalk-2016-redeploy-and-orchestration-bindings?forum=biztalkgeneral&prof=required

Add Deployable Assemblies option missing from Visual Studio 2010

I've uploaded an MVC3 website and I'm getting this error:
Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Having seen this before I know that it's an issue where the libraries I need aren't there. I have to bin deploy.
However I can't find the "Add Deployable Assemblies" option when I right click the project.
And according to this answer:
Starting with MVC 3 Tools Update we are now using Nuget package
references, which means that your project is automatically
bin-deployable. Since the tooling gesture is no longer necessary it
was removed from VS 11.
So why hasn't my application been "automatically bin-deployed" if this is the case?
Any suggestions?
Install Visual Studio 2010 Service Pack1 and you will get the option.
http://iwantmymvc.com/2011-03-23-bin-deploy-aspnet-mvc-3-visual-studio

Why the debugger doesn't work

My debugger is not working,
I'm putting a breakpoint, but in run, time visual studio doesn't stop on the breakPoint.
How to fix it?
There is nothing special in my application, it is a simple web application.
I am using visual studio 2005.
I've created a new web application project, and on the default.aspx page there is a obout grid control, on the default.cs i am filling a datatable and putting it as datatasource for the grid.
I was able to debug it, suddenly the debugger is never hit.
note that the debugger is on the load event.
Find below the steps that solved my problem:
Delete ASP.NET temporary files from C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
Change build configuration to debug from project properties.
Delete bin folder from your project.
Check if compilation debug is set to true in the web.config
iisreset
Rebuild the project.
There are a couple of things that could be wrong:
Your source code and assembly could be out of sync - rebuild the application and try again.
You could be attached to the wrong process - check to see what process you are attached to.
There could be a logical error in your code that is causing your breakpoint to not be hit (i.e. the method you are in is not actually called, logical branching is routing control around the breakpoint, etc.)
Break point was not getting hit, i cleaned and rebuild, but still not hitting, I just reopened the page (In my case Controller) and started working fine ..
When everything failed try this:
Right mouse button on your project -> Build -> untick 'Optimize code'
Or
I had similar problems when I've installed dotPeek and maybe because I don't have Resharper it was loading symbols from dotPeek symbol server but it couldn't hit my breakpoint. In that case Open dotPeek and click on Stop Symbol Server.
The symbols probably aren't loaded, that's why the breakpoint won't be hit. Did you set the website as the startup project?
When debugging, what process it attached? It should be w3wp.exe if you want to debug asp.net code.
You might need to set your application in web config so that it can be debugged..
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
You need to be running in Debug mode, and not Release mode.
Here's a detailed article about How to: Enable Debugging for ASP.NET Applications Basically, you can either set debug mode in project properties or in web.config.
try uncheck "Enable the Visual Studio hosting process"
that in project properties -> debug
worked for me
This can occur when Visual Studio is set to debug Managed code but the code is not managed (managed code is running under the control of the common language runtime (CLR)).
To fix the problem change the debug mode as shown in the right hand side of the figure below to Native only, Mixed, or Auto.
Side note: I recommend not choosing Mixed unless your system has both managed and native code (code that does not run under the CLR) because Visual Studio can't attach to an already running process in mixed mode. To debug an already running code Visual Studio need to be set to debug in Native only or Managed only.
I've seen the already existing answers have listed many possible causes, but I'd like to add one more: if you're using post-compilation tools (such as ILMerge), check whether those tools keep your debugging information (is there a .pdb file? or maybe you have embedded it in your compilation output). For those ones who are actually using AfterBuild tasks in their .csproj I really suggest to check out.
You can enable Debug as below steps.
1) Right click project solution
2) Select Debug( can find left side)
3) select Debug in Configuration dropdown.
Now run your solution. It will hit breakpoint.
Are you debugging using IIS Express instead of IIS Local. I found IIS Express sometime won't hit debug points, IIS Local works fine.
You could be like me to have both a production version (installed via a msi file) and a development version (opened in Visual Studio), and that is why I cannot get some of my breakpoints in the VS triggered today.
If that is the case you need to uninstall the production version as I think some of the dll files are interfering with my debugging session.
Clean and Rebuild your solution afterwards should fix the issue.
if you are using publish and IIS, then check your Publish configuration, make sure it says Debug
Go to publish window
[1]: https://i.stack.imgur.com/X9Dke.png
In Visual Studio 2010
Select Build > Clean {Project Name}
Rebuild Project
Now Try to rebuild project and try debug
All the best
After installing following add-on it started working. After installing, restart visual studio once. Install plug-in as per VS version.
https://download.qt.io/official_releases/vsaddin/

NUnit tests in a separate project, same solution

I have a solution containing my main project and a test project using NUnit. Everything compiles but when I run NUnit I get the exception below after the tests load, and the tests fail. I've added the main project as a reference, and I have $(ProjectDir)bin/Debug/$(TargetName)$(TargetExt) in the arguments for NUnit in the external tools setup, with a blank initial directory.
MyMainProjectTests.Database.TestAddDelete:
System.BadImageFormatException : Could not load file or assembly 'MyMainProject,
Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. An attempt was made to load a program with an incorrect format.
TearDown : System.Reflection.TargetInvocationException : Exception has been
thrown by the target of an invocation.
----> System.BadImageFormatException : Could not load file or assembly
'ChickenPing, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' or one
of its dependencies. An attempt was made to load a program with an incorrect
format.
After scouring for hours the only thing I've found is a bug in VS2005 which mentions the /bin and /obj directories, but the answer provided didn't help.
Any solutions?
Instead of setting up NUnit as an External Tool, I set the unit test project as the StartUp project. In the project's Properties screen, set the Start Action to "Start external program" and point it to nunit.exe. In the Start Options section, I specify the test assembly (no path necessary) in the "Command line arguments" box. At this point, simply press F5 to start up NUnit.
Use the nunit-x86.exe instead of nunit.exe as your runner.
A better longer term solution may be to buy ReSharper that includes a much nicer test runner for NUnit that fully integrates into Visual Studio. It auto detects your .NET project type (x68 or x64). ReShaper comes with tons of other features of which unit testing is just one. Their test runner also integrates with their DotCover code coverage analyser.
You may find that you'll need a later version of Visual Studio to use ReSharper. The latest version works with Visual Studio 2013 Community Edition that you can get for free though I understand you may have issues upgrading some project features from such a rather old VS2005 project.
I don't have any affiliation with ReSharper.
Are you running on x64? You will get that error if loading a x64 bit from x86 and vise versa. Also, the path you are trying to create should be the $(TargetPath) macro.
Just set "Platform target" of Tests project to "x86".
Is your main project a .exe or a .dll? Older versions of .NET couldn't reference an .exe, so that might be the problem.
In either case, I'd expect problems if the main assembly didn't end up somewhere accessible by your test assembly (for example, in the same directory). You could check that, and if not make it so, perhaps by having Visual Studio copy the referenced (main) assembly to the local directory.
The "An attempt was made to load a program with an incorrect format." makes me wonder if the "missing assembly" theory is right, but without more info, it's the best guess I can think of.
Go the the NUnit install (example: C:\Program Files (x86)\NUnit 2.6.3\bin) location and open nunit-86.exe.

Resources