Saturday, October 30, 2010

Free ebook: Programming Windows Phone 7 by Charles Petzold

Interested in programming Windows Phone 7?  Get the free ebook “Programming Windows Phone 7” by Charles Petzold.

Read the blog post for more information at :  http://blogs.msdn.com/b/microsoft_press/archive/2010/10/28/free-ebook-programming-windows-phone-7-by-charles-petzold.aspx

Hope that helps.

Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI  USA

Friday, June 04, 2010

On VB: What's New in Visual Basic 2010 -- Visual Studio Magazine

On June 1st, my first print article in Visual Studio Magazine was published. The article What's New in Visual Basic 2010 tells the story of how I got started in software development.  Oh, and it explores the new features of Visual Basic 2010 as well.

Hope you find it helpful.

Joe Kunk
Microsoft MVP VB
Okemos, MI USA
June 2010

On VB: Turn MS Word into a Report Writer for Silverlight 4 -- Visual Studio Magazine

On May 24th, my second web article in Visual Studio Magazine was published. The article Turn MS Word into a Report Writer for Silverlight 4 explores the new COM Automation and local File Resource features of Silverlight 4, available when Silverlight 4 runs out of browser.

Hope you find it helpful.

Joe Kunk
Microsoft MVP VB
Okemos, MI USA
June 2010

Wednesday, May 19, 2010

First “On VB” column published in Visual Studio Magazine


My first “On VB” column was published on the website of
Visual Studio Magazine.  It is titled “Calling Win32 API Functions in Visual Basic 2010” and is available at http://visualstudiomagazine.com/articles/2010/04/20/call-win32-api-functions-in-vb.aspx.

This article discusses the value of reaching beyond standard managed code and taking advantage of the functionality available in the native Win32 API, including some functionality not currently available via managed code.

Hope you find it informative and useful.

 

Joe Kunk
Microsoft MVP VB
Okemos, MI USA
May 19, 2010

Sunday, April 18, 2010

Is Silverlight 4 able to call Win32 API functions when running Out of Browser (OOB)?

With the new relaxed security model of Silverlight 4, I was curious if  would finally be possible for Silverlight to directly call Win32 API functions, particularly when running out of browser.  You could argue that it shouldn’t, as an application with such capabilities could certainly invoke unwanted behavior.  But regardless of whether it would be a good thing or not, I was still curious if it could.

After much testing it appears the answer is no. I get an error like the following when attempting to access various Win32 API functions out of browser, even after signing the assembly.

“Attempt by security transparent method 'Button1Click' to call native code through method 'Win32APIMethod' failed. Methods must be security critical or security safe-critical to call native code.”

It may be possible to use the new COM Interop capability to access these functions indirectly, but I have not tested that.

If you have any more information on this, or can show it working by providing an example, I would greatly appreciate your comments.

Hope this helps.

Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI USA

Visual Studio 2010 Keyboard Shortcut posters available

The VS 2010 Keyboard Shortcut posters are now available for download. Lisa Feigenbaum has posted the download info here:

http://blogs.msdn.com/lisa/archive/2010/04/16/vs-2010-keyboard-shortcut-posters-now-available-for-vb-c-f-c.aspx

 

Hope that helps.

Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI USA

Friday, April 02, 2010

Co-authoring the "On VB" column in Visual Studio Magazine

 

I am very pleased to announce that I have just signed on to be one of the authors of the "On VB" column in Visual Studio Magazine.  My first print article is currently scheduled to appear in the June issue.  One or more web-only articles may appear as early as May.

I have been using Visual Basic since its initial release many years ago, and DOS versions of BASIC well before that.  I am very excited to have the opportunity to make a contribution to the success of the Visual Basic language and to those that use it to develop great applications, be they personal or professional applications.

I want to thank Bill Wagner of SRT Solutions and co-author of the C# Corner column for his recommendation to join the Visual Studio Magazine writing team.  I also want to thank Michael Desmond, editor in chief of Visual Studio Magazine, for giving me this tremendous opportunity.

As Michael Desmond said when I accepted his invitation, "Game On!".

Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI  USA

Saturday, March 20, 2010

SQL Server Trigger to Log Who Created or Last Modified a Row and When

 

I implement this trigger to automatically update the CreatedOn, CreatedBy, ModifiedOn, ModifiedBy fields on almost all tables that I create in SQL Server so I decided it was time to share. 

Even if you don’t think you need this trigger, I can assure you that you will be glad you added them at some point in the future.  It is just so useful to know who created or modified the rows when data quality issues arise.

This trigger is not a full audit trail, it only retains information on the latest change.  A full audit trail would require at least one dedicated audit table and is a much more involved, whereas this is simple to implement.

It assumes a unique primary key on each table and works for both SQL user accounts and integrated security.

This example was taken from a SQL Server 2005 database.  I have successfully used the same trigger in SQL Server 2008.

Hope this helps.

Joe Kunk
Microsoft MVP VB
Okemos, MI USA

Create TRIGGER [trgMyTableCreatedModified]
ON dbo.MyTable
AFTER INSERT,UPDATE
AS
BEGIN


SET NOCOUNT ON;
Declare @now datetime
Declare @user varchar(50)

SELECT
@now = GetDate()
,@user = user_name()

UPDATE T SET
CreatedOn = COALESCE(I.CreatedOn, @now)
,CreatedBy = COALESCE(I.CreatedBy,@user)
,ModifiedOn = @now
,ModifiedBy = @user
FROM inserted I
JOIN dbo.MyTable as T
ON T.MyTableKey = I.MyTableKey

END

Saturday, January 16, 2010

Displaying External HTML file content in Microsoft MVC

 

We are developing an application where one of our MVC views is simply to render HTML snippets from an external file.  Since our favorite internet search engine did not turn up any information on how to do this, I am posting the following information. 

In our case the external HTML is a fairly simple snippet without javascript or form tags, so no manipulation of the file contents is required before display.

You can quickly read in the entire file to a string as follows:

using System.IO;

public static string GetHTMLContents(string filename)
{
string results = string.Empty;
if (File.Exists(filename))
{
results = File.ReadAllText(filename);
}
return results;
}


Then just place that string in the ViewData with a command like



ViewData["HTMLContent"] =  results;



and in the View render it with code that looks like:



<span style=" text-decoration:underline">HTML Content:</span><br/>
<%= ViewData["HTMLContent"] %>



Hope that helps.



Joe Kunk

Microsoft MVP


Okemos, MI USA


January 16, 2010

Sunday, January 03, 2010

What's New in Visual Basic 2010

 

This list is a subset of the documentation available from Microsoft on their MSDN site, provided as a learning resource. Click here to see the full page. 

Quiz yourself to see which features you fully understand.  Click the topic to see an explanation of the topic.  Note that this list is based on a unreleased version of the software and is subject to change in later releases.  Please provide updates via the comments section below.

 

Visual Basic Compiler and Language

Integrated Development Environment

 

New Visual Basic Language Samples

 

Hope that helps.

Joe Kunk
Microsoft MVP
Okemos MI USA
January 3, 2010

I like big lists and I cannot lie

 

To paraphrase the song “Baby Got Back”* by Sir Mix-A-Lot, I like big lists and I cannot lie.  (My apologies to the artist)

What I mean to say is that as the Microsoft developer space gains more capabilities and inevitably becomes more complex, it is harder for me to keep up with it all.  Long articles that explain everything step by step are wonderful, but I find it very beneficial to distill segments of these technologies down to a simple lists whenever possible and explore the individual elements in greater detail when needed. These lists give me a way to track what I already know and what I need yet to learn.

This year, I am determined to add WPF, WCF, MEF, MVC and Silverlight to the list of Microsoft .Net technologies that I can comfortably and effectively write software in.  That will involve writing lots of lists.  I look forward to sharing these lists with you on my blog.


Joe Kunk
Microsoft MVP Visual Basic
Okemos, MI USA
January 3, 2010

 

* A great song.  I was listening to it as I wrote this post.  Please support this artist and others by purchasing your music through legitimate sources that pay artist royalties.

Saturday, January 02, 2010

2010 Microsoft Most Valuable Professional in Visual Basic

I am very pleased to announce that I have been named a Microsoft MVP in Visual Basic for 2010! This is the second consecutive year that I have been the recipient of this honor.  I can hardly believe it!

I want to sincerely thank everyone that contributed to the decision to honor me with this award. 

At Microsoft I would like to specially thank PJ Forgione (MVP lead), Lisa Feigenbaum (Program Manager for Visual Studio languages), and Dustin Campbell (Visual Basic IDE Program Manager).

Locally I must thank Jeff Blankenburg, Jennifer Marsman, and Brian Prince, the best team of Microsoft Developer Evangelists that one could ever hope to work with.

I am truly humbled to be a Microsoft MVP when I consider the level of professionalism, knowledge, and community contributions represented by the Microsoft MVP community. 

Joe Kunk
Microsoft MVP
Okemos, MI USA
January 1, 2010