0

I'm using Visual studio 2017 for past few years. Now, first line of all aspx page shows below error on all my existing web applications.

Runtime error: Object reference not set to an instance of an object.

Also I tried to create a new project. It is also showing same issue. And when I try to run those project, It shows "localhost refused to connect."

enter image description here

I have tried many solutions from web. But couldn't solve the issue. What I tried are,

  • Deleted .vs folder
  • Deleted .suo file
  • Clean and rebuild
  • Uninstalled VS 2017 and reinstalled. Now I'm using version 15.9.34

UPDATE 1

I have uninstalled VS 2017 and installed VS 2019. Still showing same error for website projects. I have installed .NET frame work version V4.0.30319 and ASP.NET and web development tools. enter image description here enter image description here

user2431727
  • 877
  • 2
  • 15
  • 46
  • Being that troubleshooting requires starting at the most basic of possibilities, I have to ask: do you have asp.net installed? https://learn.microsoft.com/en-us/iis/application-frameworks/scenario-build-an-aspnet-website-on-iis/configuring-step-1-install-iis-and-asp-net-modules – Ortund Apr 12 '21 at 07:10
  • _CodeBehind=WebFrom1.aspx.cs_ what are you doing in that file? Do you have code in global.asax? Also the error has a stacktrace that should give you enough information to undestand where the error happens. – Steve Apr 12 '21 at 07:11
  • @Steve for test purpose, I have nothing written on aspx.cs. When adding any control like button or textbox this error is showing there too. – user2431727 Apr 12 '21 at 13:24
  • @Ortund yes please see my updated question – user2431727 Apr 12 '21 at 13:25
  • What's the WebForm1.aspx file look like? You need a class declared in there `public partial class WebForm1 : Page { }` – Ortund Apr 12 '21 at 13:48
  • Yes it contains.public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } – user2431727 Apr 12 '21 at 13:51
  • @user2431727, you can try to add ASP.NET Web Application(.NET Framework), choose the empty project and add an item called Web Form. – Jack J Jun Apr 13 '21 at 02:19
  • @JackJJun-MSFT Yes tried it. Still showing same error on first line of aspx. – user2431727 Apr 13 '21 at 03:43
  • 1
    @user2431727, you can try to use [/Log (devenv.exe)](https://learn.microsoft.com/en-us/visualstudio/ide/reference/log-devenv-exe?view=vs-2019) to get all activity about visual studio to see what is wrong with your vs. If this doesn't help you, please report a problem in [Developer Community](https://developercommunity.visualstudio.com/search?space=8). – Jack J Jun Apr 14 '21 at 06:16

0 Answers0