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

Tuesday, September 15, 2015

VisualStudio debug attach to process does not show w3p IIS web publishing in the list of processes

I was debugging an ASP.Net application using VisualStudio and attaching the debugger to the w3p process.
Sometimes, the list of processes to attach to, does not show the w3p process.

How-I-fixed-it:
Here are some steps, that made the w3p process appear again in the list:
- Rebuild the solution
- Restart VisualStudio
- Logout from Windows and log in again
- Open the web application to be debugged in a browser window (this finally solved the problem on my computer)

This list of steps is a "best-of" the solution, i collected from the following sources:
http://stackoverflow.com/questions/1983439/why-cant-i-attach-to-the-w3wp-exe-process-when-i-turn-off-just-my-code-in-vs201
http://stackoverflow.com/questions/4313206/cannot-attach-debugger-to-w3wp

Monday, September 9, 2013

C# LINQ Query on SQL-Server View using Entity Framework 5 returns duplicate rows because of non-unique values in records first colum

In my C# VS2012 Project I'm using EF5 to query an SQL Server 2008 R2 database. Today we run into the strange issue that a query on a view  returned the expected number of rows, but the data contained many duplicate records. Running the created SQL-query in Management Studio, the results were fine.

How-I-fixed-it:
I found the right hints here: http://stackoverflow.com/questions/3977920/entity-framework-view-return-duplicate-records
and here:
http://jepsonsblog.blogspot.in/2011/11/enitity-framework-duplicate-rows-in.html?showComment=1348809764880#c1389404724781617559

The Problem was, that the FIRST column of my view was not a unique key, which seems to confuse EF.

Running the query in Management Studio returned:

Col1,Col2,Col3
1,0,1
1,1,1
1,2,1
2,0,7

In my code the result list of records was:
Col1,Col2,Col3
1,0,1
1,0,1
1,0,1
2,0,7

According to http://stackoverflow.com/questions/3977920/entity-framework-view-return-duplicate-records it's important, that the first colum of the query result contains a unique key:

When including a view in your Entity Model, the model seems to simply use the first not-nullable columns as primary key (as all columns used in the primary key should be non-nullable).

The suggestion how to fix it is to use the ROW_NUMBER () OVER () SQL to create an additional FIRST column in you view which has unique keys. Then update the model in Visual Studio.

Sunday, September 1, 2013

IIS8 Website web.config HTTP Error 500.19 - Internal Server Error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined"

Today i copied a working website from IIS7 to IIS8. I created a new AppPool and WebApplication for it. The ApplicationPool was configured to use .NET4.0

Testing the Website, i received the following error:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler'

Config Source:
4:
5:

6:


How-i-fixed-it:
I found some useful hints here: http://www.devexpress.com/Support/Center/Question/Details/Q458935
and here:
http://www.britishdeveloper.co.uk/2010/03/there-is-duplicate-systemwebextensionss.html

I upgraded the WebProject to VisualStudio 2012. In the project properties i set the target Framework to .NET 4.5 and did a clean build.
I copied the new build to the WebApplication physical directory and it worked again.

Friday, July 5, 2013

VS 2012 keeps prompting to switch to AnkhSVN source control when opening a project checked out from Team Foundation Server

We moved a C# project that was formerly under SVN to TFS. After the inital checkout from TFS to a clean local Folder, Visual Studio kept prompting to switch to AnkhSVN. Even after setting source control to TFS manually in VS, the message kept being displayed on opening the project.

How-i-fixed-it:

I found the solution here (thanks to Haddicus):

http://msdn.microsoft.com/en-us/library/fy98ye1k%28v=vs.90%29.aspx

How to (Really): Switch Source Control Plug-ins
Although you can do as the article suggest, you may find yourself in an infinite loop. The source control system will tell you (when you select a new source control option) that the current project uses a particular control system. If this is so, it will force close you out of the project itself. In my case, at least, the source control selection was hard coded into my primary project file, and wouldn't let me switch source control.

What you'll want to do to change this is to close your solution, and open up the solution file in a text editor. Look for a global section area, this area defines the version control software. For me to change providers, all I needed to do was remove this section (everything in the GlobalSection node)... For me ( I was using Subversion with AnkhSVN), so I removed this entire block:

    GlobalSection(SubversionScc) = preSolution
        Svn-Managed = True
        Manager = AnkhSVN - Subversion Support for Visual Studio
    EndGlobalSection