Larry Brouwer

…just my technology sandbox …for my personal amusement only!

Browsing Posts in Notable

Here are some notes taken from the book Visual Studio Tipsby Sara Ford.

0-0: Look Up, Change, or Create shortcuts

  • Tools | Options (select all settings) | Environment-Keyboard | (Press shortcut-keys:)

Press the short-cut key you want to know what it does, and it will be displayed in the box below or enter the command in the (Show commands containing:) and it will show the short-cut.

1-1: Not accidentally copying blank lines

  • Tools | Options | Text Editor | All Languages | General | Uncheck the (Apply Cut or Copy commands to blank lines when there is no selection)

This will prevent the editor from clearing the clipboard when you accidentally hit Ctrl+C on a blank line.

1-2: Cycle through the Clipboard ring to paste various things

  • Ctrl+Shift+V will cycle backwards through the last 20 items in your clipboard

1-3: Inserting a line above or below the current line

  • Ctrl+Enter will open a new line above |Ctrl+Shift+Enter will open a new line below

1-4: Selecting the current word

  • Ctrl+W anywhere in a word will select the entire word.

1-5: Deleting the next word and preceding word

  • Ctrl+Del will delete the current word | Ctrl+Backspace will delete the previous word

1-6: Cutting and Deleting the current line

  • Ctrl+L will delete the current line | Ctrl+Shift+L will delete the current line

1-7: Deleting horizontal white space at the beginning of a line

  • Put cursor anywhere in white space area, then Ctrl+K + Ctrl+\ will delete the white space

1-8: Dragging sections of code (or text) to a new location

  • Use mouse to highlight section, then hold Ctrl while dragging with mouse.

1-9: Right-dragging sections of code (or text) to a new location with mouse

  • Use mouse to highlight section, then Right-Click mouse Hold and Drag code to new location
  • This allows for either Move or Copy functions.

1-10: Transposing characters, words, and lines

  • Ctrl+T for characters | Ctrl+Shift+T for words |Alt+Shift+T for lines

1-11: Upper and Lower case characters

  • Ctrl+Shift+U for Upper Case | Ctrl+U for lower case

1-12: Undo and Redo stacks on the Standard Toolbar

  • Ctrl+Z single Undo | Ctrl+Y single Redo | Look for the clockwise and counter-clockwise arrows on the toolbar to select and undo/redo multiple changes at one time

1-13: Using the mouse wheel to scroll in all directions

  • Press and hold the mouse scroll wheel. An icon appears indicating scrolling in all directions. Now move the mouse to what direction you want to scroll, i.e. up, down, right, left. The further away from the icon, the faster it moves.

1-14: Jumping to the top or bottom of the current view without scrolling

  • Ctrl+Shift+PgUp will select text from cursor to top of window
  • Ctrl+Shift+PgDn will select text from cursor to bottom of window

1-15: Hiding the vertical and horizontal scroll bars

  • Tools | Options | Text Editor | General | Display (check or uncheck)

1-16: Using Go-Back Markers to navigate forward and backwards from where you’ve been

  • Ctrl-Minus will navigate back | Ctrl+Shift+Minus will navigate forward
    In the standard Toolbar, locate the Page with Arrows forward and back. You can use these to go forward and backward multiple steps at a time.

Over the past several months, I’ve been wanting to start a journal to keep track of all the encounters of my daily programmer life. Until now, I’ve mainly used Microsoft Outlook’s Journal feature. This works fine, but it doesn’t publish it for all the world to see. What if I actually do discover something useful for others to get some good out of it? I could have taken the easy route and just used an existing blog site or facebook I suppose. But, since I’m in learning mode, why not set up my own website, with my own personal blog? What a cool idea, right? So I set off googling and stumbled upon BlogEngine.Net. This link gives you some more choices of what’s currently out there: http://csharp-source.net/open-source/bloggers It’s a customizable open source ASP.Net blog application written C#. Link to BlogEngine.Net .

For the sake of this blog entry, I’ve already got my environment ready to go.

Steps to installation:

  1. Downloaded the source code from: http://blogengine.codeplex.com/releases/view/39387 (at the time of this posting version 1.6 is current). I downloaded the source because I want to be able to see what’s going on inside.
  2. Extracted the source to my local Visual Studio projects directory. I’m currently using Visual Studio 2008.
  3. Opened the solution in VS2008. I immediately added a "Web Deployment Project" by first selecting the BlogEngine.Net project, then selecting "Build" "Add Web Deployment Project…" from the menu. The Web Deployment feature is not native to VS2008, you need to download and install it if you don’t already have it. Search on "Visual Studio 2008 Web Deployment Projects – RTW"
  4. Rebuild the application. Make sure you choose "Release" from the main menu and not debug (if you’re ready to deploy it). Then select the new deployment project "BlogEngine.NET_deploy", right click and choose build.
  5. Using explorer, go into the project directory, then into the BlogEngine.NET_deploy directory, then into the release directory. Visual Studio has created a nice deployment package for you. So now you can copy all the files from here into your web root directory.
  6. Add the new application into IIS7.
  7. Update the file permissions to the "App_Data" folder to allow for IIS7 to have write permissions.
  8. Finished setup!

Issues:

In step 2, I originally saved the solution as a zip file on my desktop. Then I extracted it with explorer to my project folder. After I extracted the solution, and opened it with Visual Studio, and VS gave me a warning message: "The project location is not trusted". Why would this be? I’ve had this error before, but it was on a file share path to a server. But this project is located on my hard drive. After some googling, I discovered a trick from leedumond.com. I needed to alter the permissions on the zip file first. So right click on the file, then select properties, then in the general tab, click the "Unblock" tab prior to extracting the file.

I had some troubles initially getting IIS7 to display the blog at first. I was getting an error screen. First, to figure out what the problem was, I went into the Web.Config file in the main folder, and changed the customErrors mode="RemoteOnly" to "Off". This allows me to see any errors from any browser, and not just on the server. The problem turned out to be file permissions on the App_Data folder. I used the procedure outlined in the installation instructions, and solved the problem straight away.

Additional thoughts:

If you’re wanting to publish the BlogEngine.Net application to a remote server, you can do it directly in VS 2008 with the Build / Publish Web Site option. You can use FTP or you’ll need the front page extensions loaded on the remote web server. See this great article: Using Visual Studio 2008 with IIS 7. Download the FrontPage 2002 Server Extensions for IIS 7.0here.

So, now, my new blogging application works great! But I wanted to take it that last step further. I wanted to hook it up to my SqlServer database. After reading the instructions, it all looked pretty straight forward. Here are the steps involved:

  1. Open up SSMS (Sql Server Management Studio).
  2. Create a new database. Let’s use blogDb.
  3. Create a new user and grant access to the new database. Let’s use blogUsr. I wanted to create a Sql Server user and not have my application log in as a Windows user. Here is the script:
    use blogDb; 
    go 

    create login blogUsr with password = ‘blogUsr’, check_policy = off 
    go 

    create user blogUsr for login blogDb; 
    go 

    grant alter to blogUsr; 
    go 

    sp_addrolemember ‘db_datareader’, ‘blogUsr’ 
    go 

    sp_addrolemember ‘db_datawriter’, ‘blogUsr’ 
    go

     
  4. Renamed Web.Config to Web.Config.Orig in the BlogEngine.Net project folder, and copied SQLServerWeb.Config in the setup\SqlServer\ directory to Web.Config in the BlogEngine.Net folder.
  5. Edited the connection string in the new Web.Config file to point to the SqlServer database. Here is the connection string used:
    <add name="BlogEngine" connectionString="Data Source=WebServer\MSSQLWEB;User ID=blogUsr;Password=blogUsrs;persist security info=False;initial catalog=blogDb;" providerName="System.Data.SqlClient"/>

  6. Bring up BlogEngine.Net in a browser and reconfigure it. Done!

Final note: I installed a utility called ieSpell which allows me to spell check my posts directly in the browser editor window.

Continuing my quest for knowledge and efficiency, I’ve come across Windows Live Writer. This little program runs quite well with BlogEngine.Net. I also downloaded and installed, Carlos Aguilar Mares’s Colorized Codeplug-in, which I used nicely in the above code section.