Navigation

Archive

<July 2009>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Categories

Blogroll

An error occurred: '=' is an unexpected token. The expected token is ';'. Line 127, position 2231.

Contact

Send mail to the author(s) Email Me


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way

Sign In
Copyright ©  2009   Jeff Klawiter . All rights reserved.

Pick a theme:
# Saturday, May 23, 2009
by Jeff Klawiter - Saturday, May 23, 2009 1:43:05 PM (Central Standard Time, UTC-06:00)

I searched far and wide and was unable to find a good quick tutorial on getting  a Visual Studio 2010 extension up and running. There are a few things wrong in the verbiage used that can be quite confusing.

Obtaining the VS 2010 Beta 1 SDK

The first order of business is to get the Visual Studio 2010 Beta 1 SDK, which will add the new templates for creating an extension.

http://www.microsoft.com/downloads/details.aspx?FamilyID=d197feb6-ced5-40d4-949d-a51f02309ee8&displaylang=en

After downloading it and trying to install it you may run across an uncaught exception (like I did)
UnHandled Exception VS 2010 SDK Installer

The error lies in the Bootstrapper (setup.exe). Since the VsSDK_sfx.exe is a self-extracting zip archive you can use your favorite unzipping utility to get the contents. (or you can take the hard way and get the files in your temp folder after it’s been unzipped). I prefer to use WinRar, it makes it extremely easy
Extracting VSSDK To Folder

After this there are only 5 files extracting.
VS SDK Unzipped

We only care about 2 of them. vssdk.cab and vssdk.msi.
Launch the vssdk.msi . This is the main installer for the SDK. It gives little feedback and will auto close when it’s done installing.

Creating Your First VS2010 Extension Project

Launch Visual Studio 2010. In your New Projects dialog under <Your Language>/Extensibility you should now have “VSIX Project”
New VSIX Project

This project defines the basic extension for visual studio. Out of this you will be able to build your VSIX file for installation into Visual Studio.

After giving your new project a name you are given a barebones extension.
New VSIX Project in Solution Explorer

The Visual Studio Extension Manifest

First we’ll start off with an unfamiliar file, the extension.vsixmanifest file. This defines your extension, from title, to license agreement to pictures. While this file is a fairly simple XML file. The VS Team provided a nice interface for editing it.
image 

While most of the form is pretty self explanatory, there are some specific points to make

  • ID: This is your global ID for your extension. After you first publish your extension, it is probably a good idea to not change this.
  • Version: this can be viewed as your installer version. It may not necessarily mirror your dll versions.
  • Supported VS Editions: This is a big one and is also forward thinking. Here you can select from all the different versions of VS2010, including Express, Integrated and Isolated Shell. It can also be expanded later to include the next version of VS.

For more information on the vsixmanifest file, see the documentation http://msdn.microsoft.com/en-us/library/dd393700(VS.100).aspx

The last two pieces are where things get interesting. There hasn’t been much said about how extensible Extensions are in VS2010.

Under References you can create references to other VS2010 extensions that your extension may depend on. Clicking on the Add Reference button gives you this dialog.
image

You’re given the options to select an extension you already have installed, add an external VSIX package or manually define one and a URL to download it from. The URL part is the real beauty. When installing your Extension it has the ability to get the latest and greatest of an extension. You can of course limit it as well to certain version numbers to avoid breaking changes. This creates a lean, mean on demand Extension.

The Content editor doesn’t seem to be fully baked. Here you can add extra content into your vsix package and have it registered upon install.  One example is a registering a Project Template. I’ve borrowed an example from the Card Game Starter Kit .

image

 

The Code

You will find one lone code file in your new project. Here is the CS version

using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.VisualStudio.ExtensibilityHosting;

/// <summary>
/// Empty VSIX Project.
/// </summary>
namespace MyFirstVs2010Extension
{

}

Not much in there. This is where your imagination comes in

Here is where I’ll leave you to fend on your own for now. Navigating the Visual Studio SDK assemblies is another post all in itself.  You’ll find all assemblies you need under the Microsoft.VisualStudio namespace in your add references dialog. It is also possible to tie into Team System via the Microsoft.TeamSystem .

For some full source examples of VS 2010 Extensions, check out the Editor Samples on codeplex
http://editorsamples.codeplex.com/

# Friday, May 15, 2009
by Jeff Klawiter - Friday, May 15, 2009 4:31:39 PM (Central Standard Time, UTC-06:00)

I gave a talk on Microsoft Small Basic last night at the Twin Cities Languages User Group. I promised to post my materials and here they are.

The zip contains the powerpoint presentation file, the example programs and the example extension.

For the guy that asked about mp3s. It looks like they will work as long as the computer it’s running on has an mp3 codec installed (which is very unlikely).

Comments [0] #       |  kick it on DotNetKicks.com
# Tuesday, April 07, 2009
by Jeff Klawiter - Tuesday, April 07, 2009 11:12:30 AM (Central Standard Time, UTC-06:00)

Just a quick post here for the people that attended my presentation. Thank you for coming to listen to me blabber about snippets and little tips and tricks. I hope you found it of some use.

Comments [0] #       |  kick it on DotNetKicks.com
# Wednesday, March 18, 2009
by Jeff Klawiter - Wednesday, March 18, 2009 5:41:54 PM (Central Standard Time, UTC-06:00)
With the release of Silverlight 3 Beta we can now run PixelShader effects on any control. This can produce some powerful stuff as shown during the Mix 09 Keynote this morning. I delved in as fast as I could to find out how to make your own and work with them in VS.

I downloaded the WPF shader library from http://wpffx.codeplex.com/ . I only imported the ShaderEffectLibrary so far, I have not tried the transition one.

I simply copied the EffectFiles, ShaderSource and EffectLibrary.cs files into my project and tried to compile.  Issues I ran into
  1. UIPropertyMetadata needs to be replaced with PropertyMetadata
  2. Color.FromScRgb needs to be replaced with Color.FromArgb and it's inputs run through Convert.ToByte
  3. MagnifyEffect.cs and SwirlEffect.cs reference classes that do not exist in Silverlight like the Vector class. I could have got them from reflector but in sake of time I didn't (that and being able to release this code)
  4. Getting the ps resources required a minor change to the Global static class. Basically changing the path to do a Relative URI lookup.
The basics here for doing your own shader effects is included save 1 thing. You need the DirectX SDK to compile your HLSL code. You can add a new build event or do it from the commandline. This is a good tutorial on how to do it http://windowsclient.net/wpf/wpf35/wpf-35sp1-hlsl-primer.aspx.

So the basics of doing your own Pixel shader in Silverlight is damn near identical as WPF. You inherit from the ShaderEffect class, load your compiled HLSL bytecode resource and expose any properties you need to modify as dependency properties.

Attached is my ugly but working example. I couldn't find anyway to bind to properties on an effect so I had to just do it by event.

SlShaderEffectDemo.zip

Comments [2] #      HLSL | Silverlight 3  |  kick it on DotNetKicks.com
# Wednesday, December 17, 2008
by Jeff Klawiter - Wednesday, December 17, 2008 11:05:58 AM (Central Standard Time, UTC-06:00)
For those of you still playing with the VS2010 and .NET 4.0 CTP bits, be aware that it will stop working on Jan 1st. MS has not released any word if we will be getting an updated CTP or a beta anytime soon. This is a bit unlike them where they had a bit of overlap between a VS CTP and the beta.

There are some ways around this. I found a nice post that covers some of the options and links to the information
http://blogs.msdn.com/granth/archive/2008/12/10/visual-studio-2010-ctp-vpc-will-expire-jan-1-2009.aspx

Basically you need to disable time syncronization for the VPC image.

I was worried about this since the get go. I wanted to do some talks coming up on .NET 4.0 and the new parallelism features but it's very hard to do that when you're not sure if you'll even have a working copy to demonstrate on.

Comments [0] #       |  kick it on DotNetKicks.com
# Tuesday, December 09, 2008
by Jeff Klawiter - Tuesday, December 09, 2008 9:25:58 AM (Central Standard Time, UTC-06:00)
Well I took my MCPD: ASP.NET 2.0 test yesterday and passed. It has been just over a year since I took my .NET 2.0 Foundation test. In that time I've taken MCTS for windows and web and now MCPD. There are many more certs to go. Next stop I think are the new .NET 3.5 TS certs.

Comments [0] #       |  kick it on DotNetKicks.com
# Tuesday, October 28, 2008
by Jeff Klawiter - Tuesday, October 28, 2008 11:29:58 AM (Central Standard Time, UTC-06:00)
I'm definitely installing this one when I get a chance. http://channel9.msdn.com/posts/briankel/PDC2008-ShowOff-Entry-Clipboard-History-for-Visual-Studio/

Basically it keeps a history of your clipboard items like Office but with one killer twist. "Paste as {Language}". It will take the C# you copied and Paste it as VB. I'm sure it's not 100% but still helps quite a bit.

Comments [0] #      Visual Studio  |  kick it on DotNetKicks.com
by Jeff Klawiter - Tuesday, October 28, 2008 10:23:43 AM (Central Standard Time, UTC-06:00)
All of these new C# 4.0 dynamic features require parts of the DLR. Thus it looks like MS is taking the DLR and making it a first class citizen in the CLR. This also I'm guessing will make IronPython and IronRuby first class citizens as well. A huge win for the dynamic languages community. For C# 4.0 it is bittersweet. It means better interoperability when calling things created in IronRuby or IronPython but there are limitations. Below is an excerpt from the C# 4.0 WhitePaper (available here http://code.msdn.microsoft.com/csharpfuture)

Open issues

There are a few limitations and things that might work differently than you would expect.

·         The DLR allows objects to be created from objects that represent classes. However, the current implementation of C# doesn’t have syntax to support this.

·         Dynamic lookup will not be able to find extension methods. Whether extension methods apply or not depends on the static context of the call (i.e. which using clauses occur), and this context information is not currently kept as part of the payload.

·         Anonymous functions (i.e. lambda expressions) cannot appear as arguments to a dynamic method call. The compiler cannot bind (i.e. “understand”) an anonymous function without knowing what type it is converted to.

One consequence of these limitations is that you cannot easily use LINQ queries over dynamic objects:

dynamic collection = …;

var result = collection.Select(e => e + 5);

If the Select method is an extension method, dynamic lookup will not find it. Even if it is an instance method, the above does not compile, because a lambda expression cannot be passed as an argument to a dynamic operation.

There are no plans to address these limitations in C# 4.0.


To me this is a very huge limitation. I can already see that most of my interop with dynamic languages will probably involve collections of some sort. Also this would come into play with collections from Dynamic COM objects. LINQ is so powerful and easy to use, it may end up being a major annoyance to have to move away from it for dynamic typing. I hope they work on this for C# 4.5


Comments [0] #      C# 4.0  |  kick it on DotNetKicks.com
by Jeff Klawiter - Tuesday, October 28, 2008 8:13:13 AM (Central Standard Time, UTC-06:00)
While browsing through MSDN blogs I came across this nice little post. http://blogs.msdn.com/dparys/archive/2008/10/28/neue-m-glichkeiten-in-c-4-0.aspx . After translating the page I found that he linked to the new C# 40 page http://code.msdn.microsoft.com/csharpfuture

I played around with VS 2010 last night. I was able to test the dynamic keyword. It works as advertised but the biggest thing one has to realize is using it removes intellisense for that variable. Compiling type safety as well. I hope they'll be able to add some sort of limited intellisense by looking at the last assigned type.

Also on the Dynamic front is DynamicObject. A new base object type that allows for on the fly Property declaration. The DynamicObject uses a PropertyBag (looks like a Dictionary<string,object>). You can declare properties on the fly. Like
public class MyBag : DynamicObject
{
// überschreibt Getter / Setter
} 
dynamic b = new MyBag();
b.Id = 124;
b.Name = "Windows 7"
b.Price = 499.99m;
b.IsAvailable = false;

One thing I was unable to figure out was the optional, default and named parameters. Again the blog provided some answers.

public void InsertCustomer( int customerId,
                          string companyName = "Neue Firma",
                          decimal creditLimit = 2000m )
{
}

InsertCustomer( 1, creditLimit: 2000m );  

InsertCustomer( creditLimit: 2000m, customerId: 1 );





Comments [0] #      C# | C# 4.0  |  kick it on DotNetKicks.com
# Monday, October 27, 2008
by Jeff Klawiter - Monday, October 27, 2008 7:03:34 PM (Central Standard Time, UTC-06:00)
Well I spent most of the day working on some peculiar problems with PICK. Then left to take my girlfriend out for her birthday. Just now catching up on whats gone on today at PDC. Man it seems like it was a huge day.

First off Windows Azure and the new .NET Services. From what I've read so far I can see some compelling uses for the .NET services and sharing content, id's and roles around the web.

The big one that I haven't seen much press on yet is C# 4.0. Looks like we are getting dynamic binding in the language. While this loses compile type safety it gives C# good ground against things like Ruby and PHP.

Named, Optional and Default parameters. Oh how I've been waiting for these since switching to .NET from PHP. I used to take advantage of these features all the time. It annoys me when I can use them in Attributes in C# but not on actual methods. I'm going to love this.

VS2010 and C# will CTP are available in a virtual PC here

Here's a better overview stolen from http://blogs.msdn.com/samng/archive/2008/10/28/microsoft-visual-studio-2010.aspx
  1. Dynamic binding. We've introduced a new type, dynamic, which behaves much like object, but allows the operations performed on your object to be bound at runtime instead of compile time.
  2. Named and Optional parameters. You can now specify default values for your parameters, allowing them to be optionally specified at the call site. We've also added the ability for your arguments to be passed by name, so that you can specify exactly which arguments you want to give, and refrain from specifying the rest (assuming they're optional).
  3. Com interop features. We've done quite a bit of work to improve COM interop. These include:
    • No ref for COM calls. For all COM calls that take ref arguments, you can specify an argument without a ref, and the compiler will generate a local for you and generate a ref to that local as the argument.
    • No PIA. We have introduced the ability to deploy your applications which use Primary Interop Assemblies (PIAs) without referencing the actual PIA at runtime. This allows compiling against them, but not needing to ship them with your application.
    • Implicit dynamic for COM types. We now give you the option of turning all objects returned from COM into dynamics so that you can perform late bound calls off of them instead of having to cast the result in order to make it useful.

Comments [0] #      C#  |  kick it on DotNetKicks.com