Saturday, January 7, 2017

Convert to Web Application: "The name 'objectName' does not exist in the current context"

If you're updating an old project into a web application, select the solution in the Solution Explorer, and then select to Project -> Convert to Web Application in the top menu:

This will create .aspx.designer.cs files in your project.   But you may run into the following error next:

   "The name 'objectName' does not exist in the current context"

If so check that you have the namespace declared around your class in the .aspx.designer.cs file, the Convert to Web Application action doesn't always add it:

namespace My.Namespace

    public partial class Default


You may also need to update the Page Directive's Inherit attribute to include the namespace:

<%@ Page ... Inherits="Default" %>


<%@ Page ... Inherits="My.Namespace.Default" %>

Friday, January 6, 2017

Creating an output file with date and timestamp from the command prompt

Here's a quick and easy way to create a timestamp when outputting from the command prompt:

myscript.bat > myscript_%date:~-4%-%date:~4,2%-%date:~7,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%.log