Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Friday, October 20, 2017

VS 2017 Error - Unable to start program http://localhost An operation is not legal

Scenario
You are trying to debug a web site in Visual Studio 2017

Error
Microsoft visual studio is giving the error: Unable to start program http://localhost An operation is not legal


Solution
Disable the JavaScript debugging

  • On VS go to Tools >> Options
  • Go to Debugging >> General
  • Uncheck the option Enable JavaScript debugging for ASP.NET (Chrome and IE)
  • Click OK and try again

Wednesday, October 18, 2017

VS 2017 MVC Core 2.0 error - Cannot find reference assembly 'Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86.exe' file for package Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86

Scenario

After compiling a MVC Core 2.0 project in VS 2017, the browser isn't displaying the site

Error
An unhandled exception occurred while processing the request.

Cannot find reference assembly 'Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86.exe' file for package Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86

Solution
Open the .csproj file in a text editor
In the section set the MvcRazorCompileOnPublish tag as true:
      <mvcrazorcompileonpublish>true</mvcrazorcompileonpublish>

Tuesday, October 17, 2017

VS 2017 MVC Core 2.0 publish fails

Scenario
Publish a MVC Core 2.0 project in Visual Studio 2017

Error
Severity
Error
Code
The command ""bin\Release\net461\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86.exe"
Description
@"obj\Release\net461\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1


Solution
Open the .csproj file in a text editor
In the section set the MvcRazorCompileOnPublish tag as false:
      <mvcrazorcompileonpublish>false</mvcrazorcompileonpublish>

Tuesday, October 10, 2017

MVC Core - Duplicate Content Error after Upgrading Visual Studio 2017

Error

  • Dotnet-aspnet-codegenerator-design has stopped working
  • Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default.
  • Failed to build the project. Please fix the build errors and retry again


Reason

The problem is a change on the RC3 release of Visual Studio 2017, if you have globs in your project and you try to build it using the newest SDK, you'll get the error. Basically your content, such as the files in wwwroot are now getting imported by the default includes that are built-in to Visual Studio and by the manual rules in your csproj file.


Solution 1

Open your web project file .csproj and remove the duplicated items specified in the error message


Basically remove the ItemGroup tag with all the wwwroot paths.



Solution 2

Open your web project file .csproj
Look for the tag
Add the next tag false


Thursday, April 28, 2016

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

If you get the error:

HTTP Error 500.22 - Internal Server Error

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.


Looks like you upgraded recently your project to a newer version.
To solve this problem, follow the next steps:
* In Visual Studio, select your web project
* In the properties section set the Managed Pipeline Mode to Classic
* Compile and re-run the web application



Tuesday, November 10, 2015

When publishing an application using ClickOnce I get the error: Value does not fall within the expected range

Sometimes when you publish an application with ClickOnce in Visual Studio, when you do an upgrade, some users get something like this:
ERROR DETAILS
    Following errors were detected during this operation.
    * [11/10/2015 10:35:30 AM] System.ArgumentException
     - Value does not fall within the expected range.
What you need to do to fix the problem is clean the App Cache, to do it, run the next command:
rundll32 %windir%\system32\dfshim.dll CleanOnlineAppCache
Another way to solve it is to clean the Apps folder in the user's machine
%user%\AppData\Local\Apps
If this does't work, uninstall the application in the Control Panel from the user's machine and reinstall it.



Wednesday, September 30, 2015

VS 2013 - “The breakpoint will not currently be hit. The source code is different from the original version.”

If you are getting the next error:


This generally occurs when the dll and the dll source code are different or if the .pdb file information is not matching.

A quick solution is:

  • Delete the /bin folder 
  • Delete the /obj folder
  • Recompile the project

Friday, September 18, 2015

Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

If you are getting the next error when deploying your web application:

Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.


or the next error:

Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.


or this one:

Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.


Or maybe other files, the reason is the .dll is missing in the published site.
To solve the problem in visual studio:

  • Expand the References folder
  • Click on the file missing
  • On the properties section go to the Copy Local option
  • Change the value from False to True

This should fix the problem.

Friday, August 7, 2015

Visual Studio “Could not copy... Exceeded count to 10.Failed” during build


Error:
Error   10  Could not copy "obj\Debug\MyApp.Controlls.dll" to
 "bin\Debug\MyApp.Controlls.dll". 
 Exceeded retry count of 10. Failed.    


Error   41  Unable to copy file "obj\Debug\MyApp.exe" to
"bin\Debug\MyApp.exe". The process cannot access the file
'bin\Debug\MyApp.exe' because it is being used by another 
process. 

Cause:
 Most of the time this occurs when the debug process was stopped somewhere in an exception.

Solution 1:
 

Try to Build >> Clean Solution, then Rebuild project


Solution 2:
 

Close Visual Studio, delete the 'bin' and 'obj' folders, then rebuild the project


Solution 3:
 

Go to task manager, localize your project exe file and kill it, then rebuild the project

Thursday, June 12, 2014

Steps to set startup page for debugging in asp.net mvc aplication

To set the start page in Visual Studio for a MVC application, follow the next steps:

  1. Got to Projects >> Properties...
  2. Click the Web Tab
  3. Select the Specific Page radio button
  4. Type the URL in the Specific Page text box


Friday, March 11, 2011

VS debugger comes up, may stop on a break, but quickly stop

If the debugger sometimes comes up, may stop on a break, but quickly stops, and the asp.net web page continues running, but the IDE is returned from a debug state to an edit state, the problem is that if script debugging is enabled on IE, your debug state will stop when a popup window is opened. Turning this option off inside internet explorer advanced options makes everything work again.

To Disable Script Debugging in Internet Explorer
1.In Internet Explorer, choose Internet Options from the Tools menu.
2.In the Internet Options dialog box, click the Advanced tab.
3.On the Advanced tab, under Browsing, clear Disable Script Debugging.
4.Click OK.

Wednesday, September 22, 2010

Debugging AJAX in VS



To debug Ajax you have to do it as the code is executing in the browser.
You write out a debug message using Sys.Debug.trace.
Your page must include the Microsoft AJAX Library JavaScript file. This is done by adding a ScriptManager control to your page.

The following code shows part of an .aspx page that includes a ScriptManager control and a JavaScript function named button1_onclick.
When this function is fired (from the user clicking button1), the trace method is called.











You can view the trace messages output by the AJAX library in the Visual Studio Output window.




Thursday, September 2, 2010

Windows Installer is not included in any selected prerequisite




If you are working on a setup project and you get the warning:
Windows Installer is not included in any selected prerequisite

This means you need to add a prerequisite to you application, in order to fix it follow these steps in visual studio:

  1. In the solution explorer, right-click on your deployment project and select Properties;
  2. A window titled " Property Pages" should appear
  3. Click on the Prerequisites... button
  4. Select a package that installs Windows Installer 2.0
  5. Click OK button and re-build again.

This should remove the warning





Tuesday, August 31, 2010

Special folders in a VS web site

Special folders in a VS web site.

Special folders can be added to a Web site from the Visual Studio menu system. Typically
this involves right-clicking the Web application project and selecting Add ASP.NET Folder.

Folder NameDescription
App_BrowsersContains browser definition files (.browser) that ASP.NET uses
to identify browsers and determine their capabilities. These
files are often used to help support mobile applications.
App_CodeContains source code for classes and business objects (.cs,
.vb, and .jsl files) that you want to compile as part of your
application
App_DataContains application data files (.mdf and .xml files)
App_GlobalResourcesContains resources (.resx and .resources files) that are compiled
into assemblies and have a global scope. Resource files
are used to externalize text and images from your application
code. This helps you support multiple languages and
design-time changes without recompilation of source code
App_LocalResourcesContains resources (.resx and .resources files) that are
scoped to a specific page, user control, or master page in an
application.
App_ThemesContains subfolders that each define a specific theme (or
look) for your site. A theme consists of files (such as .skin,
.css, and image files) that define the appearance of Web
pages and controls.
App_WebReferencesContains Web reference files (.wsdl, .xsd, .disco, and .discomap
files) that define references to Web services
BinContains compiled assemblies (.dll files) for code that you
want to reference in your application. Assemblies in the Bin
folder are automatically referenced in your application


Friday, August 6, 2010

Change default language in Visual Studio





  1. Tools
  2. Import export settings wizard


  3. Reset all settings


  4. No, just reset settings, overwriting my current settings
  5. Select the default collection of settings (C#, VB, etc.)
  6. Finish



Monday, August 2, 2010

Auto align assignments on VS10

  1. Download "Productivity Power Tools" for VS10, from here, then install it.
  2. Select your code then press Ctrl+Alt+]
These are the results:
Before


After



Wednesday, March 17, 2010

No errors when debugging but breakpoints are not hit on Visual Studio



In order to fix this problem you need to be sure that all the modules in your project are enabled for debugging, some times the main is enabled but the rest are not, this would give you the apparency of no errors but breakpoints on the modules not enabled will cause the debugging to stop.

To enable debugging right click on each project and select "Properties".
A window like the one on the image below should appear.
On 'Enable ASP.NET Debugging" select "True"
Click "Apply" then close.
The debug has been enabled for this module, repeat the process for all projects.






Friday, February 5, 2010

Missing item templates in Visual Studio 2005

If you try to add an item (Class, Form, etc.) and you notice there is one or more templates missing, sounds like something went wrong with the cache on disk of all the installed item templates.

Here you have two possibles ways to solve the problem:


First option
Close Visual Studio then Open the ‘Visual Studio 2005 Command Prompt’.
Type the following command at the prompt, press enter and wait a couple minutes.
devenv /installvstemplates

Second option
Open the Options window in Visual Studio.
Select Projects and Solutions.
Change the Visual Studio user item template location to the folder where the standard templates are located:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates