Unable to Start Apache – Xampp

Hey everyone,

I was mucking around with xampp this morning and ran into the following issue with apache:

3:41:52 PM [main] Initializing Control Panel
3:41:52 PM [main] Windows Version: Windows 8 Pro 64-bit
3:41:52 PM [main] XAMPP Version: 5.6.3
3:41:52 PM [main] Control Panel Version: 3.2.1 [ Compiled: May 7th 2013 ]
3:41:52 PM [main] You are not running with administrator rights! This will work for
3:41:52 PM [main] most application stuff but whenever you do something with services
3:41:52 PM [main] there will be a security dialogue or things will break! So think
3:41:52 PM [main] about running this application with administrator rights!
3:41:52 PM [main] XAMPP Installation Directory: “c:\xampp\”
3:41:52 PM [main] Checking for prerequisites
3:41:52 PM [main] All prerequisites found
3:41:52 PM [main] Initializing Modules
3:41:52 PM [Apache] Problem detected!
3:41:52 PM [Apache] Port 80 in use by “Unable to open process” with PID 7820!
3:41:52 PM [Apache] Apache WILL NOT start without the configured ports free!
3:41:52 PM [Apache] You need to uninstall/disable/reconfigure the blocking application
3:41:52 PM [Apache] or reconfigure Apache and the Control Panel to listen on a different port
3:41:52 PM [Apache] Problem detected!
3:41:52 PM [Apache] Port 443 in use by “Unable to open process” with PID 7820!
3:41:52 PM [Apache] Apache WILL NOT start without the configured ports free!
3:41:52 PM [Apache] You need to uninstall/disable/reconfigure the blocking application
3:41:52 PM [Apache] or reconfigure Apache and the Control Panel to listen on a different port

In order to fix this, you can just kill the process that is blocking the port. Unfortunately I had IIS on this and needed another solution. As always, stackoverflow had the answer:

– In the xampp control panel, click config (same line as apache) and open the httpd.conf file
– Search for listen 80 and change it to list 8080 (or an alternative free port)
– Save and close the file
– In the xampp control panel, click config (top right)
– Click service and port settings and change the main port (and ssl if necessary) to match your httpd.conf file
– Click save and restart apache (note you may also need to run as administrator)

Check out this link for more info: http://stackoverflow.com/a/25113205/522859

Resources for Mocking WCF

Hey everyone,

Just a few links I came across for mocking WCF in case anyone else needs them.

This tutorial was great: http://weblogs.asp.net/cibrax/unit-tests-for-wcf

The only issue being that it was missing a few class definitions (IIncomingWebRequestContext and IOutgoingResponseContext). I got lucky and was able to find full code samples at the following links:

https://code.google.com/p/netfx/source/browse/trunk/Source/ServiceModel/Web/IIncomingWebRequestContext.cs?r=18

http://netfx.googlecode.com/svn-history/r28/trunk/Source/ServiceModel/Web/Wrappers.cs

Just in case these links ever go down:

http://pastebin.com/CjUMwhsG
http://pastebin.com/F1Fj9eRC

No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’ – MVC5

Hey everyone,

Just an error I came across while trying to use a new solution project:

No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’

The fix for this was simply to run the following command in the package manager console:

1
PM> Install-Package EntityFramework

Thanks to StackOverflow for the details: http://stackoverflow.com/a/18642452/522859

Change Default MVC5 Password Complexity Requirements – Passwords must have at least one non letter or digit character. Passwords must have at least one digit (‘0′-‘9′). Passwords must have at least one uppercase (‘A’-‘Z’)

Hey everyone,

I’ve started on a new MVC5 project and came across the following error message while trying to register a new user:

Passwords must have at least one non letter or digit character.
Passwords must have at least one digit (‘0′-‘9′).
Passwords must have at least one uppercase (‘A’-‘Z’)

While having a secure password is obviously important, I felt that most users would probably find these requirements a little extreme. After a bit of Googling I came across a StackOverflow post that mentioned a config class that you can use to edit these settings:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// App_Start > IdentityConfig.cs
 
...
 
// Configure validation logic for usernames
            manager.UserValidator = new UserValidator<ApplicationUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit = true,
                RequireLowercase = true,
                RequireUppercase = true,
            };
 
...

Unescape String in Watch Window – Visual Studio

Hey everyone,

Just a quick post on how to remove the escape characters from a string in the watch window. All you’ve got to do is append “,nq” (short for no quotes) to the watch variable name.

1
MyLongString becomes MyLongString,nq

This removes all of the quotes and line breaks. Pretty handy for when you’ve got to copy the values.

Check out these links for more info:

MSDN: http://msdn.microsoft.com/en-us/library/e514eeby%28v=vs.100%29.aspx
StackOverflow: http://stackoverflow.com/a/9786653/522859

How to Open the Same File Twice in Visual Studio

Hey everyone,

Today I was working on a fairly large class and needed to compare two different areas of code. I’m used to using text editors such as notepad++ and sublime where I would normally just open the file multiple times. It turns out that Visual Studio has a similar feature, although it’s admittedly a lot less intuitive:

– Open the file you want to duplicate and make it the active tab (just click on it somewhere)
– Select window from the menu up the top
– Click New Window

This will duplicate your active tab. To place them side by side simply right click on one of them and then select ‘New Vertical Tab Group’.

Thanks to this Stackoverflow post for the solution: http://stackoverflow.com/a/772159/522859

View Generated SQL in Entity Framework (EF)

Hey everyone,

Just a quick post on how to view the generated sql in entity framework. To start with, just add the following line to your db context constructor:

public class TestDbContext : DbContext
    {
        public TestDbContext() : base("name=TestDbContext")
        {
            this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); //This line
        }
        ...

With this line added, you should now be able to see all of your generated sql in the output window.

SELECT TOP (1) 
    [Project1].[VidId] AS [VidId], 
    [Project1].[CreatedAt] AS [CreatedAt], 
    [Project1].[CHECK] AS [CHECK], 
    [Project1].[SourceCheck] AS [SourceCheck]
    FROM ( SELECT 
        [Extent1].[VidId] AS [VidId], 
        [Extent1].[CreatedAt] AS [CreatedAt], 
        [Extent1].[CHECK] AS [CHECK], 
        [Extent1].[SourceCheck] AS [SourceCheck]
        FROM [dbo].[Vids] AS [Extent1]
        WHERE [Extent1].[VidId] < @p__linq__0
    )  AS [Project1]
    ORDER BY [Project1].[VidId] DESC
 
-- p__linq__0: '535' (Type = Int32)
-- Executing at 28/06/2014 5:00:16 PM +10:00
-- Completed in 0 ms with result: SqlDataReader

If you’re not using EF6, there were a few other options where I came across this solution: http://stackoverflow.com/a/20751723/522859

Dragging a File from File Explorer Causes Google Chrome to Crash

Hey everyone,

A team member found an interesting bug today that caused chrome to go non-responsive. The cause was simply dragging a file from the file explorer onto a drag and drop upload area. It is reproducible on every site I’ve tested, including Gmail and Dropbox.

Reproduce

  • Go to https://mail.google.com
  • Click compose
  • Click attach files (close any of the annoying popups that appear)
  • DRAG a number of files from the file selector window to the new message screen (they will start to upload) (IMPORTANT: these need to be dragged from the file selector popup, NOT a new explorer window)
  • While they are still uploading hit cancel on the file browser window. Browser will go non-responsive

A bug has been reported here: https://code.google.com/p/chromium/issues/detail?id=388661

How to Open the Same File Twice in Visual Studio

Hey everyone,

I was working on a fairly large class in visual studio and having a bit of trouble comparing two different areas within it. Thankfully, StackOverflow knew of a way to make things a lot easier – open the same file twice:

– With the tab you want to duplicate currently active, select Window from the menu
– Click new window
– On the new window, right click and select ‘New Vertical Tab Group’ from the drop down

How to stop text taking up more than one line – CSS

Hey everyone,

Just a quick post on how to stop text taking up more than one line using only CSS:

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

You can check it out using this fiddle: http://jsfiddle.net/wb5m7/
There’s also a great StackOverflow post: http://stackoverflow.com/a/572302/522859