Kevin Grohoske

Senior Software Engineer 
MCPD-WEB, MCPD-WIN, MCSD

A first look at Visual Studio 2010 (VS2010)

Tuesday, June 16, 2009 06:24 | posted by: kevin

Microsoft’s marquee development tool is poised to make some great strides in making .NET developers even more productive than they are already today. Though it is still only Beta 1 and MS does not plan to release the tool until late 2010, there is a significant numbers of features that appeared to be production ready (along with a few that are currently promised for Beta 2).

Looking around

On first glance there is something different about the UI/UX. It may be that the graphics team is still cleaning up the look and feel or it could be that the IDE is written using WPF. Either way it definitely needs a bit of refinement in my opinion. On the bright side the new tool will support dual monitors.

If you into test driven development there is a whole new menu section dedicated to TDD. I haven’t had time to look at the particulars, but it is encouraging to see some MS effort in this space.

Extension Manager promises to be beneficial by providing sample project templates, directly from the IDE, that follow best practices guidelines.

Help is more helpful by linking to Sample Applications from MSDN directly.

Coding Is King

One of my favorite IDE shortcuts is the new “Generate Class From” context menu that allows you to write a declaration like below you can right click on the NewObject() and choose “Generate Class From”. This will create a new class file using the object name and create the stub for the class. Additionally you can right click on the Methods and generate the method stubs, including parameter types, for each method.

NewObject newObj = new NewObject();
newObj.FirstMethod();
string new str = newObject.SecondMethod(5);

Another feature that is long overdue and helps when working on very large projects is if you right click on a method declaration name or call you can choose to see the View Call Hierarchy, which allows you to see when the method is defined and all instances in the project where the method is called. Goodbye find in project searches to determine all of the locations a method is called.

Welcome to C# Optional and Named Parameters! If you done any VB development, you have long used optional parameters and perhaps even named parameters. Now they have been introduced in C#. They are structured a bit differently in C#, but are easy enough to use. You simply add a default value to the parameter in the method signature.

Optional Parameter Example -

// This Code:
public void ExampleMethod(int requiredInt){...}
public void ExampleMethod(int requiredInt, string optionalString)
{
//do something with optional string
ExampleMethod(requiredInt)
}
// Becomes:
public void ExampleMethod(int required, string optionalString=null){..}

I’m curious how many snobbish C# folks will switch from overloaded methods though. I know these people they don’t play nice and were hated on the playground.

Name Parameters go hand-in-hand with Optional Parameters in C# because you need to use named parameters to call methods with Optional Parameters. You cannot simply use the VB notation ExampleMethod(x, , y). Empty parameter clauses will error out so you dothe following when calling a method with optional parmeters. In your method signature all optional parms need to be defined last, just as in VB.

// method signature
public void ExampleMethod(int required, string optionalString=null, string optionalString2){..}
ExampleMethod(requiredInt: 4,){...}
// only optionalparams need to be named
ExampleMethod(4, optionalString2: "test"){...}
// OR all param's named which is legal and more readable
ExampleMethod(requiredInt:4, optionalString2: "test"){...}

There are a couple new Data Types also in C#:

  • BigInt, which is the equivalent to BigInt in JAVA, will be used for most commonly for encryption keys.
  • And dynamic…

Ah dynamic a regression of a data type that was not well received at my presentation. Dynamic is like object, in that it can hold any data type, but !!!! it can also be used to call any method or property on the object. Unlike all other things in C# dynamic is well… dynamic … or non-statically typed. In other words you do not need to know what type the object will hold, only how to use it. You will not get a compile error if you attempt to use a method or parmeter that is not available for the object, you will only get run-time errors when attempting to use the object improperly.  For example with dynamic all the following is legal:

dynamic d1 = 7;
dynamic d2 = <span style="color: maroon">"a string"</span>;
dynamic d3 = System.DateTime.Today;
dynamic d4 = System.Diagnostics.Process.GetProcesses();
//casting back:
int i = d1;
string str = d2;
DateTime dt = d3;
System.Diagnostics.Process[] procs = d4;

Yes, it will be abused (so don’t hire hacks). Yes, it will remain because it was created for Ruby, Python, and other dynamically typed languages. It will be very handy for Office API calls and late-binding!!!

Multi-targeting will extend from .NET Framework 2.0 to .NET Framework 4.0 (including Client Profile). 4.0 Framework Client profile will not be a web installation only and will now support 64-bit. It will also include new classes such as EntityFramework run-time, Extensibility Framework, Dynamic types, Parallel Programming (nope I haven’t mentioned that yet), and some support for WCF.

Another one of my favorite demo’s is the code snippets. If you get a chance find out more about these. I can see this improving development efforts and increasing productivity for software shops with internal coding standards.

Ok. I’ll stop for now… But there is plenty more!!!

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

On Tuesday I presented, “Getting the Most Out of SharePoint” at the Web Technologies Conference in Spanish Fort, AL, which was co-sponsored by Microsoft, The Gulf Coast Technology Conference, and Bit-Wizards.

Despite a few technical glitches and last minutes emergencies, the entire day went very well. I received a ton of very positive feedback about how the presentation had a good balance between technical and ‘C’ business type level content, which is great because that was the tightrope I was trying to walk. If you’ve never given a technical presentation, you can’t appreciate how difficult it can be to find the right balance.

During intermissions I had a great time mingling and telling old war, IT horror, and Cincinnati/Dayton stories with attendees. I hope we get to do more of these because SharePoint adoption is growing by leaps and bounds, but in the haste to implement too many people (IT and Business teams) are painting themselves in a corner or not getting the ROI they could, thus it becomes SharePoint’s fault.

I don’t think we’ve published our slide deck yet so below are highlights of my presentation:

SharePoint should become the hub of your business activity-

  • The built-in resources/features should be leveraged for all future Intranet applications.
  • Imagine productivity gains by not having to start from scratch security/reporting/search/workflow/forms when developing Line of Business (LOB) applications
  • If you dream it… it can be done.

Have A Plan -

  • It is not just an application you install and run with - that is the recipe for failure Business and IT Stake Holders should be involved Develop and communicate the following:
    • Governance Document
    • Business Requirements
    • Project Plan
    • Project Design
    • Branding Design
    • Training Plan

Integrate it with Existing Applications and Data Extend ROI by keeping existing business systems - 

  • Any line of business (LOB) application that .NET technologies can communicate with can be integrated with SharePoint
  • You can integrate existing web applications or use the underlying data in SharePoint
  • Let SharePoint be the ecosystem for your Intranet applications

Brand Your SharePoint - It’s not a question of Fashion or Function – you can have both

  • Out of the box SharePoint 2007 looks dated and plain
  • Branding will help ‘sell’ SharePoint up and down the organization chart
  • For extranets you can extend your corporate brand to vendors and outside companies alike

Microsofts’ SharePoint is the 800lbs gorilla and will continue to get better.

  • Fastest growing server product
  • 100+ million licenses sold
  • 1 billion in revenue in FY08
  • Growth of 35% over FY07

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Visual Studio 2008 SP1 & Framework 3.5.1 Features Presentation

Friday, March 06, 2009 06:15 | posted by: kevin

At the last Gulf Coast .NET User Group, I presented the following slides. There are a number of great features in Service Pack 1 release of VS 2008 and 3.5.1 Version of the .NET Framework. Here are couple quick things to keep in mind.

  •  VS 2008 SP1 and 3.5.1 Framework are pretty much a lockstep upgrade.
  • I call the framework 3.5.1 because MS released a service pack for the framework soon after releasing 3.5.
  • MVC is not part of this release of the framework and is still a separate install. It will likely be a part of 4.0 Framework due out this year.

Visual Studio SP & .NET 3.5.1 Framework Features Presentation

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

A long time ago before the world of Visual Studio’s Integrated Web Server and .NET you had to test web sites a bit more “manually”. Here is one trick that is a somewhat lost art.

If you want to test your web application and/or web service (very handy trick for web services)  for some reason you need it to be at a specific URL, such as http://www.testingURL.com. You will need to assign a separate IP address for your web site/webservice.

On windows servers and desktops, you can modify the “hosts” file (note there is no file extension). If you have not modified this file it should look like the following:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

To add a new entry simply type the ip address of the actual location of the test web site/web service you are working with (ex.  222.22.22.222). And then type the “fake” name of the URL (ex. testingURL.com)

With the above information your entry into the “hosts”:

222.22.22.222    testingURL.com

Once you save this file all requests for testingURL.com will now go to the ip address 222.22.22.222.

The beauty of this solution is that you can bind a WS call to your production web service while developing and all requests get routed to your test web service! Once in production, all the calls will be routed to your production web server.

On Windows 2003 and XP the “hosts” file is located at -  C:\windows\system32\drivers\etc

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Inaccessible logs: Security Error On Windows Server 2008 in IIS7

Friday, September 05, 2008 06:02 | posted by: kevin

We use a custom exception handler which utilizes the MS Enterprise Library Exception Block. I recently had an ASP.NET page I was testing that failed a test and I received “Inaccessible logs: Security Error” message.

Problem:

Root problem is the first time a ASP.Net application attempts to write to the Event Log an exception type for that application is created. In this case the Application Pool was running as the “NetworkService” identity.

Solution:

Simple fix is to change the identity that the Application Pool is running as an identity that has administrative privileges. In this case, I switched the identity to “LocalSystem”. Run the offending page again one time and the exception’s event type is created, then switch the Application Pool’s Identity back to “NetworkService”.

 

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Hidden _EventValidation Element Breaks 1.1 Framework Applications on IIS7

Wednesday, August 13, 2008 05:24 | posted by: kevin

Yesterday a few of us at the office had to track down a frustrating bug/feature that prevented ASP.NET 1.1 Framework web application from running on Internet Information Server 7 (IIS7) and Windows Server 2008 (Windows 2008).

Situation:

We host several client sites on our public hosting server. We migrated the 1.1 Framework Applications to Windows 2008 / IIS7 running the pool pipeline in ‘classic mode’. One site appeared to work fine, except that a button on a particular page did now work. It appeared as if the asp:button, which is generated in the HTML as a Submit button, did not post back to the server. The button did work on the Windows Server 2003 / IIS6 environment.

Problem:

We finally determined, after several hours, that the problem was due to:

  • non-standard coding practices of using a ‘get’ action type in a ASP.NET form
  • a very large dropdownlist (more than 2000 records)
  • 2.0 Framework security in IIS7 adding a hidden form element called “__EVENTVALIDATION”.

The combination of these factors together caused an extremely large URL to be created during the ‘get’ request. Large URL’s use to cause buffer overflow issues, so the IIS7 team wisely has added a security feature to reject large URL requests. II7 security rejected our request with a 403 (or possibly a 404) Http error code.

Solutions:

1. You can set your @Page directive to disable event validation for that page - EnableEventValidation = “false”

<%@ Page Language=”vb” AutoEventWireup=”false” Codebehind=”yourpage.aspx.vb” Inherits=”namespace.yourpage” EnableViewState=”false” EnableEventValidation=”false” %>

2. You can set your web.config to disable event validation for that page

<location path="yourpage.aspx"> <system> </system></location> <pages enableeventvalidation="false"></pages>

Note: these solutions are not compatible with II6 and Windows Server 2003!! I do not know of a solution that would be forward and backwards compatible.

A little more about Event Validation from MSDN:

The EnableEventValidation attribute indicates whether event validation should be performed. The default value is true. A Web application can optionally disable event validation to revert to .NET Framework version 1.0 behavior.

Event validation reduces the risk of unauthorized postback requests and callbacks. It instructs ASP.NET to validate only those events that can be raised in the control during a postback request or callback. With this model, a control registers its events during rendering and then validates the events during the post-back or callback handling. All event-driven controls in ASP.NET use this feature by default.

When event validation is enabled a hidden input field is appended on to the bottom of your HTML form like the following:

<input type=”hidden” name=”__EVENTVALIDATION” id=”__EVENTVALIDATION” value=”/wEWigsCgoLO0gICm7n0HQLngYvWCQLogc…”/>

Depending on the size of the content within your controls this may be several hundred or several thousand characters long.

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Handy VS.NET IDE Shortcut for Tabs and Spaces

Wednesday, April 09, 2008 05:18 | posted by: kevin

Here is a comprehesive list of VS 2005 keyboard shortcuts.

My esteemed co-worker Matt Parry-Hill pointed one that he uses that is worth highlighting:

Within a codebehind or class file press Ctrl-R then Ctrl-W and you will get -> and . for the tabs and spaces within your code. 

 Also, don’t forget that you can turn on line numbering by >Tools>Options>Text Editor>All Languages and check the line numbers option.

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Microsoft released a Beta Release of Internet Explorer 8 today. I have not downloaded it yet, but from everything I’ve read it should be W3C compliant and sport some new features found on other browsers, which should reduce some of the MS haters arguments. I strongly support the current MS strategy of embracing standards, it makes building solutions on MS technology much easier and makes the IT worlds a better place. I will post more after I get my hands on it. I use both IE(6&7) and Mozilla based browsers, depending on what I’m doing and what UI I want for any given task. So I really don’t get too wrapped up in the discussion about which browser is best, no matter how often Joe Healy tries.

Another interesting tidbit is that is that it will default to Acid2 default mode by default and will have three modes as MS states in this press pass:

“Internet Explorer 8 has been designed to include three rendering modes: one that reflects Microsoft’s implementation of current Web standards, a second reflecting Microsoft’s implementation of Web standards at the time of the release of Internet Explorer 7 in 2006, and a third based on rendering methods dating back to the early Web. The newest rendering mode is forward-looking and preferred by Web designers, while the others are present to enable compatibility with the myriad sites across the Web that are currently optimized for previous versions of Internet Explorer.”

Here is a deeper investigation of the impacts of the three rendering modes:

 ”When IE8 eventually ships, it will have three rendering modes, two of which are the already familiar “quirks mode” and “(not so) standards mode.” In an IE team blog entry, IE Platform Architect Chris Wilson revealed a third mode that can be invoked by developers:

  1. “Quirks mode” remains the same, and compatible with current content.
  2. “Standards mode” remains the same as IE7, and compatible with current content.
  3. If you (the page developer) really want the best standards support IE8 can give, you can get it by inserting a simple <meta> element.

This third mode will use a <meta> tag to specify that a page should use the behavior of a specific browser version. To get IE8 really-standard-this-time-we-mean-it behavior, a page will include an element like <meta http-equiv=”X-UA-Compatible” content=”IE=8″ />. That says that a page should use IE8’s behavior—and should use it even in IE9, IE10, or any future version. The first two modes will continue to use the doctype switch to choose between them.”

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  

Study Finds .NET has overtaken Java

Wednesday, November 28, 2007 04:40 | posted by: kevin

This report is very interesting and should be looked at closer before touting it around the office. I have worked with both languages and find .NET’s Language, IDE, and framework much more productive and decreases development costs.

Info-Tech Group study finds that .NET has overtaken Java in the enterprise.

Tags:

PermaLink   E-Mail Article   RSS Comment Feed  
<asp:DropDownList id=”State” runat=”server”>
<asp:ListItem Value=”AL”>Alabama</asp:ListItem>
<asp:ListItem Value=”AA”>Armed Forces the Americas</asp:ListItem>
<asp:ListItem Value=”AE”>Armed Forces Europe</asp:ListItem>
<asp:ListItem Value=”AP”>Armed Forces Pacific</asp:ListItem>
<asp:ListItem Value=”AK”>Alaska</asp:ListItem>
<asp:ListItem Value=”AS”>American Samoa</asp:ListItem>
<asp:ListItem Value=”AZ”>Arizona</asp:ListItem>
<asp:ListItem Value=”AR”>Arkansas</asp:ListItem>
<asp:ListItem Value=”CA”>California</asp:ListItem>
<asp:ListItem Value=”CO”>Colorado</asp:ListItem>
<asp:ListItem Value=”CT”>Connecticut</asp:ListItem>
<asp:ListItem Value=”DC”>District of Columbia</asp:ListItem>
<asp:ListItem Value=”DE”>Delaware</asp:ListItem>
<asp:ListItem Value=”FL”>Florida</asp:ListItem>
<asp:ListItem Value=”FM”>Federal States of Micronesia</asp:ListItem>
<asp:ListItem Value=”GA”>Georgia</asp:ListItem>
<asp:ListItem Value=”GU”>Guam</asp:ListItem>
<asp:ListItem Value=”HI”>Hawaii</asp:ListItem>
<asp:ListItem Value=”ID”>Idaho</asp:ListItem>
<asp:ListItem Value=”IL”>Illinois</asp:ListItem>
<asp:ListItem Value=”IN”>Indiana</asp:ListItem>
<asp:ListItem Value=”IA”>Iowa</asp:ListItem>
<asp:ListItem Value=”KS”>Kansas</asp:ListItem>
<asp:ListItem Value=”KY”>Kentucky</asp:ListItem>
<asp:ListItem Value=”LA”>Louisiana</asp:ListItem>
<asp:ListItem Value=”ME”>Maine</asp:ListItem>
<asp:ListItem Value=”MD”>Maryland</asp:ListItem>
<asp:ListItem Value=”MH”>Marshall Islands</asp:ListItem>
<asp:ListItem Value=”MA”>Massachusetts</asp:ListItem>
<asp:ListItem Value=”MI”>Michigan</asp:ListItem>
<asp:ListItem Value=”MN”>Minnesota</asp:ListItem>
<asp:ListItem Value=”MS”>Mississippi</asp:ListItem>
<asp:ListItem Value=”MO”>Missouri</asp:ListItem>
<asp:ListItem Value=”MT”>Montana</asp:ListItem>
<asp:ListItem Value=”NE”>Nebraska</asp:ListItem>
<asp:ListItem Value=”NV”>Nevada</asp:ListItem>
<asp:ListItem Value=”NH”>New Hampshire</asp:ListItem>
<asp:ListItem Value=”NJ”>New Jersey</asp:ListItem>
<asp:ListItem Value=”NM”>New Mexico</asp:ListItem>
<asp:ListItem Value=”NY”>New York</asp:ListItem>
<asp:ListItem Value=”NC”>North Carolina</asp:ListItem>
<asp:ListItem Value=”ND”>North Dakota</asp:ListItem>
<asp:ListItem Value=”MP”>Northern Mariana Islands</asp:ListItem>
<asp:ListItem Value=”OH”>Ohio</asp:ListItem>
<asp:ListItem Value=”OK”>Oklahoma</asp:ListItem>
<asp:ListItem Value=”OR”>Oregon</asp:ListItem>
<asp:ListItem Value=”PW”>Palau</asp:ListItem>
<asp:ListItem Value=”PA”>Pennsylvania</asp:ListItem>
<asp:ListItem Value=”PR”>Puerto Rico</asp:ListItem>
<asp:ListItem Value=”RI”>Rhode Island</asp:ListItem>
<asp:ListItem Value=”SC”>South Carolina</asp:ListItem>
<asp:ListItem Value=”SD”>South Dakota</asp:ListItem>
<asp:ListItem Value=”TN”>Tennessee</asp:ListItem>
<asp:ListItem Value=”TX”>Texas</asp:ListItem>
<asp:ListItem Value=”UT”>Utah</asp:ListItem>
<asp:ListItem Value=”VT”>Vermont</asp:ListItem>
<asp:ListItem Value=”VA”>Virginia</asp:ListItem>
<asp:ListItem Value=”VI”>Virgin Islands, U.S.</asp:ListItem>
<asp:ListItem Value=”WA”>Washington</asp:ListItem>
<asp:ListItem Value=”WV”>West Virginia</asp:ListItem>
<asp:ListItem Value=”WI”>Wisconsin</asp:ListItem>
<asp:ListItem Value=”WY”>Wyoming</asp:ListItem>
</asp:DropDownList>

Tags:

PermaLink   E-Mail Article   RSS Comment Feed