Visual Studio 11 : The ClassView / Solution Explorer Combo Platter

Like many of you, I?ve been tinkering around with the betas for VS 11.  While one of the *big* changes is the deep XAML designer tools (which are in many ways lifted right from Expression Blend), one of the little features I?d like to point out is the enhanced Solution Explorer perspective.

Recall: This part of the IDE (in any version) will list out the current files in a given project, as well as assembly references. For example, in VS 2010, we might find the following:

image

While seeing your files is useful, often times you are more interested in the assemblies namespaces, types and members. Thus, you would normally flip over to the Class View perspective:

image

Under Visual Studio 11, the Solution Explorer has been updated in such a way, that you can get the best of both worlds. Notice that each file now has an option to expand the file to reveal a tree showing all types in the file, and their members:

image

Again, sometimes the little things mean a lot!


Posted by: Andrew Troelsen
Posted on: 1/19/2012 at 1:58 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

Portable .NET Class Library

Sometimes the little things mean a lot. For example, if you have downloaded the .NET 4.5 Developer Preview, you might have noticed a new *.dll project type named a Portable Class Library:

image

As the name implies, this project type allows you to build a reusable class library which can be consumed by multiple platforms which support the .NET framework. Specifically, this type of library allows you to build logic which can be consumed by a Windows executable, a Silverlight application, Windows Phone 7 and Microsoft Xbox. 

The key is that when you add references to framework libraries, you are only shown a limited subset of assemblies which are guaranteed to run on each target platform. Consider the following screen shot of the ?Add Reference? dialog:

image

You are also able to control which platforms you wish to target via the project?s Properties editor:

image

So, all things considered, this new class library project should make it much simpler and ?fool proof? to build a library which can easily be used across various .NET aware devices. Nice!


Posted by: Andrew Troelsen
Posted on: 1/3/2012 at 2:18 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

Naming Conventions of the .NET Crypto APIs

Recently I had a need to dive into the System.Security.Cryptography namespace. Here, you will find a number of types which allow you to program for common crypto-centric situations, including (but not limited to):

  • Data integrity via hash code values.
  • Confidentiality via shared-key and public-key cryptography.
  • Authentication via digital signatures.

As you look at the various classes contained in System.Security.Cryptography you will notice that collections of classes have a similar common suffix (for example, ?Managed or ?Cng). One point of confusion is that you will find what appear to be redundant classes for common cryptographic algorithms. To hopefully clear the air and simplify your life just a bit, here is a quick rundown on the framework?s naming conventions.

The Microsoft .NET platform was originally designed for creating applications for the Windows family of operating systems; however it is now possible to develop .NET programs for other operating systems as well (such as Mac OS X or Linux)[1]. With this in mind, be aware that any security class marked with the ?CryptoServiceProvider suffix (ex: TripleDESCryptoServiceProvider) depends on the Windows specific Cryptography API (CryptoAPI) and is not guaranteed to be portable across operating systems.

In contrast, a number of framework security classes are written completely in managed code. Any class marked with a ?Managed suffix (ex: RijndaelManaged) is not tied to the CryptoAPI and can be used on any operating system which supports the .NET platform.

Finally, as of .NET version 3.5, Microsoft released a third set of security implementations which use the heir apparent to CryptoAPI, Cryptography Next Generation (CNG). CNG classes end with a ?Cng suffix by convention (ex: ECDiffieHellmanCng). While the CNG types are specific to the Windows family of operating systems, they are compliant with the National Security Agency (NSA) Suite B specification[2].

So there you go. Should you need to build out a crypto library for your projects, I hope this little cheat sheet will help in some way.


[1] Mono is the most popular OS-neutral implementation of the .NET framework (www.mono-project.com).

[2] http://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml


Posted by: Andrew Troelsen
Posted on: 12/21/2011 at 8:25 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

Excellent Java E-Book (recommended by a .NET guy)

This week has been a real treat for me- I have put my instructor hat aside and picked up my very dusty ?student-in-a-class? hat. For years, I have wanted to take Intertech?s Complete Java class to better understand how the other half live (as many of you know, I have spent my time in the .NET world). My prime reason for taking the Java class was to better relate to Java developers who come to my C# / VB classes.

Anyway, in the Complete Java class, each chapter has a nice list of additional resources, one of which I have downloaded and felt was good enough to let you all know. David Eck, a professor at  Hobart and William Smith Colleges, as authored a number of extremely good books you can download for free.  First:

Introduction to Programming Using Java, Sixth Edition

At first look this might appear to be yet another Java book.  What I find really nice is that it is a very deep treatment of the subject, covering details such as complexity of algorithms (big O notation), binary trees, ADTs (abstract data types) and recursion. A nice refresher for concepts we might not think about on our day to day business app development.

This same author also provides the following free E-Book:

Foundations of Computer Science

This is another great read. Remember *years* ago when you learned about formal grammars, turing machines, sets and functions, formal logic and computability?  Me too.  Do you remember much of the details?  Me either.  This free book is a great review of the plumbing of computer science.  I really recommend this one.

Anyway, back to the Complete Java class!


Posted by: Andrew Troelsen
Posted on: 12/9/2011 at 12:17 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

Silverlight?

So, if you are currently following the stories of Silverlight, Windows Runtime / Metro and .NET 4.5, you may have some confusion regarding where Silverlight sits in the land scape of Microsoft development. Well, you are not alone!  Part of the problem (as always) is the ?InterWeb?.  Do a web search on some phrase such as ?Is Silverlight Dead? and you will get numerous conflicting answers.

In a nutshell, it does seem that Microsoft is putting it?s money in HTML 5 as the champ of interactive web content. Furthermore, given that the forthcoming Windows 8 OS (and the related Metro style apps) are built using a whole new technology stack,  it does seem that the Silverlight we know today may have a limited scope (and possibly a limited lifetime).

However!  The spirit of Silverlight will live on.  As you might know, a Metro style app is constructed using the same core tools .NET programmers are already familiar with. You will build such apps using a managed language (C# or VB) or via C++. As well, XAML (or HTML 5) will be used to build out your overall UI. So the *good* news is, developers who are currently using Silverlight (or WPF for that matter) will be in a very good position to build Metro apps when Windows 8 is released.

You?ll use Visual Studio and Blend, reference assemblies and import namespaces, and build away.

As far as Silverlight proper, this will still be a useful tool for some time to come (if you ask me).  The first obvious reason is that all of IT is not going to rush into installing Windows 8 across the workplace (regardless of what we geeks might desire). Computers running Windows XP or Windows 7 will still be able to display Silverlight applications as expected. As well, if one boots up the traditional desktop from Windows 8, and launches the ?traditional? set of web browsers, Silverlight apps should run as advertised.

Even though the overall scope of Silverlight may be changing, it is worth pointing out that Silverlight 5.0 (which has recently been released) ships with numerous bells and whistles. As a quick rundown:

  • Implicit data templates
  • ClickCount support
  • Improved styles
  • Custom markup extensions
  • An improved 3D graphics API

It should not be too surprising that many of these ideas will migrate (in a slightly different manner) to Metro and .NET 4.5.

So, if you are currently building Silverlight apps, check out the new features offered by 5.0.  If you are not currently building Silverlight apps, you might wish to at least read over the key features here, to get a better idea of what life may have in store for the future.


Posted by: Andrew Troelsen
Posted on: 11/28/2011 at 10:22 AM
Categories: Silverlight | .NET
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

UML and Visual Studio? Yes please!

Visual Studio has supported visual class designers for quite some time.  As useful as these features are, the one problem is that the diagram produced is *not* UML proper, but a ?UML-like? notation.

Awhile back, Microsoft released a Visual Studio Feature Pack for MSDN subscribers which allows you to generate proper UML diagrams (of various flavors). You can download this feature pack by clicking on the ?Visual Studio 2010 Feature Pack 2? link at this web site.

Once you have installed the feature pack, you will be able to:

  • Use the Generate Code command to generate skeleton code from elements on UML class diagrams. You can use the default transformations, or you can write custom transformations to translate UML types into code.
  • Create UML class diagrams from existing code.
  • Explore the organization and relationships in C, C++, and ASP.NET projects by generating dependency graphs.
  • Import elements from UML sequence diagrams, class diagrams, and use case diagrams as XMI 2.1 files that are exported from other modeling tools.
  • Create links and view links from work items to model elements.
  • Create layer diagrams from C or C++ code and validate dependencies.
  • Write code to modify layer diagrams and to validate code against layer diagrams.

Just to give a taste, assume you have a current C# project, and which to generate some UML class diagrams. First, from the Architecture menu option, select New Diagram.  From here, you can pick from any of the following:

image

Assuming you select a new UML Class Diagram, you can open the Architecture Explorer window, and drag types onto the created visual designer:

image

The resulting UML is then generated by the tool:

image

Another great feature of this feature pack is the ability to generate dependency graphs of your code. For example, if you were to select the Architecture | Generate Dependency Graph menu option, you will find a diagram such as the following:

image

There is much more you can do with this feature pack, and if you have an MSDN subscription ID, I?d say it is certainly worth a download!

Happy coding.


Posted by: Andrew Troelsen
Posted on: 11/14/2011 at 2:09 PM
Categories: .NET | Visual Studio
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

So what would YOU like to see in an ?advanced? C# class?

Hello everyone, I have something to ask?.

At intertech, we have a wide variety of .NET and Java classes; however our entry points are Complete C# / Complete VB / Compete Java.  These classes take a deep dive into the syntax and semantics of the language under investigation and then examine several key APIs of the platform.

Beyond these foundational classes, we offer a number of API specific classes.  For example, in the .NET space, we have dedicated classes on LINQ, WCF, ASP.NET, WPF, Silverlight and so on.  Thus, one could consider these ?advanced? classes.

However, if Intertech were to offer an ?Advanced C# / .NET class?, what would you like to see covered? The trick is, keeping things API neutral to a large extent if possible. The other trick is trying to think of topics that would apply to a wide audience. It seems that most people define an ?advanced class? as ?a collection of topics that map directly to what I am doing at work right now??.but that of course can?t apply to everyone.

I have my list of topics I am tinkering with, but I?d love to hear what you think.

If you have ideas on what you might like to see in a possible Advanced C# / .NET class, pop me an email (atroelsen@intertech.com). Be sure you include AdvancedClass in the subject somewhere so things filter correctly.

Thanks all!

Andrew


Posted by: Andrew Troelsen
Posted on: 10/31/2011 at 9:25 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

A Few Helpful Visual Studio 2010 Code Snippets

When I teach the Complete C# class here at Intertech, I do a number of live demos with the class.  During that time, I try to show as many useful code snippets has possible. 

Many .NET programmers are unaware of the built in code-snippets of VS 2010.  Basically, a code snippet is a XML document that defines data such as the name of the code snippet, which code to dump in the editor when the snippet is activated, and any ?placeholders? in the snippet.

One thing to be aware of is that the C# and VB code editors each treat code snippet technology a tad different, so for this post, I?ll show how to work with a snippet within a C# project.

You can activate a code snippet in a few ways.  If you happen to know the name of the snippet you are trying to activate, just type it by name.  You?ll notice the icon for a code snippet looks a bit like a torn piece of paper (at least to me!). For example, let?s say you wish to iterate over incoming command line arguments for a Main() method of an executable. Simply type in the work ?foreach?:

image

Once you find the snippet, press the TAB key twice on your keyboard.  The first time will autocomplete any partial typing of the snippet (ex: fore for foreach) but the second TAB will execute the code placement:

image

Now, keep clicking the Tab key.  You will see focus will transfer to any ?placeholders? you need to fill in. Since we are iterating over a string array, we can type in string for the first placeholder, tab over the second (item is a fine enough name) and then tab to the third placeholder and substitute ?collection? with args (the name of the incoming string array).  Once you are done, you can find the following:

image 

Once you are happy with your placeholder values, press the Esc key to exit ?snippet mode? (be aware!!  Once you exit snippet mode, there is no way to return!  If you need to change anything, you will need to do so manually, or delete the code and start again).

Now, in the scope of the foreach loop, type in cw TAB TAB (cw is a handy code snippet for the first set of labs of the C# class, as it dumps a Console.WriteLine() call). At this point, just print out the name of the current string in the loop:

image

Beyond foreach and cw, Visual Studio 2010 has numerous code snippets. For example, if you need to build a custom System.Exception derived class which conforms to best practices, just type exception TAB TAB somewhere in a namespace scope.

Strictly speaking, VS 2010 supports two types of code snippets.  The first batch are simple snippets that dump code at the current position of the text caret in the editor. You can view all snippets of this category by right clicking in your code editor and selecting the Insert Snippet?. context menu:

image

At this point you will find a list of al snippets (possibly arranged into categories based on what you have installed on your DEV machine) and a bit of help text.  Make sure to take some time to try out a few which interest you.

image 

The other category of code snippets are termed ?Surround with snippets?.  As the name implies, you first select a set of code statements, right click on the selection, and pick a snippet. The selected code will then be wrapped in the snippet?s scope. For example, let?s say you want to wrap your foreach logic in a custom #region / #endregion. Begin as so:

image

Then pick #region from the menu selection:

image

Once again at this point, you can specify any required placeholders.

image

Beyond using the built in code snippets, you can certainly build your own!  Many moons ago (2005 I believe?) I wrote an article for MSDN about how you can build custom code snippets. You can view this article at the MSDN web site here.

So there you go.  A few helpful thoughts on working with code snippets. Enjoy!


Posted by: Andrew Troelsen
Posted on: 10/31/2011 at 9:07 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

Up and Running with the Windows 8 Developer Preview

Just last week (Sept 13-16, 2011) Microsoft unloaded a slew of new technologies at the build conference which took place in Anaheim, CA. Here, attendees were shown:

  • A tech preview of Windows 8 (and the new Metro UI)
  • A tech preview of Visual Studio 11 (and the associated .NET 4.5 bits)
  • A tech preview of Blend 5 (with all new new HTML 5 support)
  • Tons of code sample, details of WinRT and other items of interest (dust of your C++ skills people!)

Thankfully, all of this new tech was bundled into an ISO image which can be download free of charge. Once installed, you can begin to tinker with the bits, and see how your life as a Windows developer will be changing once again.

Here is a walk through on how to obtain and install all of the bits ? and all of the build conference session talks ? so you can hit the ground running.

First, you need to download the ISO image, which can be found here.  You will find three ISO options, but you?ll want to grab the Windows Developer Preview with developer tools English, 64-bit (x64) option. It is a large image (almost 5GB), so be patient. Also be aware, this is TOO BIG to fit on a standard DVD. You?ll need a high capacity DVD or local disk storage.

Next, you will need some virtual machine software (assuming you are not going to install the ISO on a test machine). I tried installing the image using various options, but I found that VirtualBox worked best for me, so I?ll recommend you use this same tool, which can be downloaded freely for Mac or Windows here.

Great. Now you have the two binary images you need to install the Windows 8 Dev Preview. At this point, I would suggest you navigate to the following post on the Technically Personal website.  Raju PP has written a very clear, step-by-step walkthrough on the process of creating a new VirtualBox image for the Windows 8 Tech Preview (thanks Raju!). 

Once the entire process has completed, you will be walked through the initial preparation of your Windows OS install (user name, password, Windows Live ID, etc.).  When all is said and done, lo and behold, Windows 8:

image

Attempting to dive in at this point can be daunting. The OS UI is quite new, the technology previews of Visual Studio and Blend are full of dozens of new templates, APIs and tools. Therefore, my next suggestion is to download and read the Windows Developer Preview Guide PDF authored by Microsoft. Here, you will find a concise overview of the big rocks.

Last but not least, you will want to get your hands on the build conference session talks. While you could spend time hunting down each talk online, Michael Crump has authored a very helpful post on how you can download all of the talks locally using Juice or PowerShell. Check out the details here.

So there you go!  At this point all you need is a strong pot of coffee, and endless hours of time to tinker Winking smile

Happy coding.


Posted by: Andrew Troelsen
Posted on: 9/19/2011 at 9:32 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed

The Role of Reflection in VB (.NET)?Part 2

In an earlier post, I explored how VB developer?s can leverage the .NET reflection API to dynamically discover the composition of a type. The sample code of that post illustrated how to build a ?quick and dirty? object browser with one significant limitation: You can only reflect over types within the always present mscorlib.dll assembly!

As it turns out, the reflection API also supports the concept of dynamically loading assemblies at runtime via the Assembly class. Let?s see how it works.

Using the Assembly type, you are able to dynamically load private or shared assemblies, as well as load an assembly located at an arbitrary location on your hard drive. In essence, the Assembly class provides methods (Load() and LoadFrom() in particular) that allow you to programmatically supply the same sort of information found in a client-side *.config file.

To illustrate dynamic loading, create a brand-new Console Application named ExternalAssemblyReflector. Your task is to construct a Main() method that prompts for the friendly name of an assembly to load dynamically. You will pass the Assembly reference in to a helper method named DisplayTypes(), which will simply print the names of each class, interface, structure, enumeration, and delegate it contains. The code is refreshingly simple:

   1:  Imports System.Reflection
   2:   
   3:  Module Program
   4:    Sub Main()
   5:      Console.WriteLine("***** External Assembly Viewer *****")
   6:      Dim asmName As String = String.Empty
   7:      Dim asm As Assembly = Nothing
   8:      Do
   9:        Console.WriteLine()
  10:        Console.WriteLine("Enter an assembly to evaluate")
  11:        Console.Write("or enter Q to quit: ")
  12:   
  13:        ' Get name of assembly.
  14:        asmName = Console.ReadLine()
  15:   
  16:        ' Does user want to quit?
  17:        If asmName.ToUpper = "Q" Then
  18:          Exit Do
  19:        End If
  20:   
  21:        Try ' Try to load assembly.
  22:          asm = Assembly.Load(asmName)
  23:          DisplayTypesInAsm(asm)
  24:        Catch
  25:          Console.WriteLine("Sorry, can't find assembly named {0}.", asmName)
  26:        End Try
  27:      Loop  
  28:    End Sub
  29:   
  30:    Sub DisplayTypesInAsm(ByVal asm As Assembly)
  31:      Console.WriteLine()
  32:      Console.WriteLine("***** Types in Assembly *****")
  33:      Console.WriteLine("->{0}", asm.FullName)
  34:      Dim types As Type() = asm.GetTypes()
  35:      For Each t As Type In types
  36:        Console.WriteLine("Type: {0}", t)
  37:      Next
  38:        Console.WriteLine()
  39:    End Sub
  40:  End Module

Notice that the shared Assembly.Load() method has been passed only the friendly name of the assembly you are interested in loading into memory. Thus, if you wish to reflect over a custom private library, you will need to copy the binary to the \bin\Debug directory of the ExternalAssemblyReflector application to run this program. If you wish to load a library from any arbitrary location, replace the call to Load() with LoadFrom(); at that point you can enter an absolute path to the binary to load into memory.

Now, at this point you might wonder how you can load a library from the GAC?  We will check that possibility out in a later post ;-)


Posted by: Andrew Troelsen
Posted on: 9/6/2011 at 4:20 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Subscribe to this BlogRSS comment feed
Contact Us 651-994-8558 1-800-866-9884
Home | Training | Curriculum | Course Finder | Schedule | Enroll | Twin Cities Java User Group | Consulting | Foundation | Jobs | About Us | Our Story | Press Room | Instructors | President | Map & Directions | Sitemap

Java Training | JSF / Struts / Spring / Hibernate Training | Java Power Tools Training | .NET 4.0 & Visual Studio 2010 Training | .NET 3.5 and Visual Studio 2008 Training | .NET 2.0 and Visual Studio 2003 Training | Prism / MVVM / MEF Training | Microsoft Web Development Training | Cloud Computing Training | Ajax / Web Services / XML Training | Groovy and Grails Training | SQL Server 2008 Training | SQL Server 2005 Training | Mobile Development Training | SharePoint 2010 Training | SharePoint 2007 Training | Agile, Process, Analysis & Design Training | Arch/Design Patterns Training | Microsoft Official Curriculum Training | Web Development Training | Ruby Training | Rational Application Developer (RAD) Training | WebSphere Application Server Training | WebSphere Portal Training | WebLogic Training | Boot Camp Training | Project Management Training | C++ Training | Metro / WinRT / Windows 8 Development Training | Retired

Intertech delivers training on-site and virtually serving cities including Phoenix, AZ | San Francisco, CA | Los Angeles, CA | San Diego, CA | San Jose, CA | Washington, DC | Chicago, IL | Orlando, FL | Boston, MA | Duluth, MN | Minneapolis St. Paul, MN | Rochester, MN | Raleigh-Durham, NC | New York, NY | Philadelphia, PA | Austin, TX | Dallas, TX | Houston, TX | Seattle, WA.