##############################################################################################
# AzureCmdPrompt.ps1
##############################################################################################
function SetupAzure($installPath, $netPath)
{
$curPath = $env:path;
$binPath = $installPath + "bin";
$env:PATH = $binPath + ";" + $curPath + ";" + $netPath;
$env:ServiceHostingSDKInstallPath = $installPath;
echo "Windows Azure SDK PowerShell";
$host.ui.RawUI.WindowTitle = "Windows Azure SDK Environment"
}
if (!$env:ServiceHostingSDKInstallPath)
{
if (test-path "hklm:\software\microsoft\microsoft sdks\servicehosting\v1.0")
{
$installPath = $(gp "HKLM:\Software\Microsoft\Microsoft SDKs\ServiceHosting\v1.0").InstallPath
$net64Path = "$env:SystemRoot\Microsoft.NET\Framework64\v3.5";
$net32Path = "$env:SystemRoot\Microsoft.NET\Framework\v3.5";
if (test-path $net64Path)
{ SetupAzure $installPath $net64Path }
elseif (test-path $net32Path)
{ SetupAzure $installPath $net32Path }
else
{ echo "Please install the .NET 3.5 Framework."; }
}
else
{ echo "Please install the Windows Azure SDK."; }
}
Saturday, December 20, 2008
Windows Azure for Powershell
The Azure SDK includes a setenv.cmd batch file for an Azure Command Prompt. But I haven't used the Command Prompt in ages! Powershell or bust! So.. Here's my Azure PowerShell Prompt script. Add it to the end of your profile.ps1 in the %USERPROFILE%\Documents\WindowsPowerShell folder and go make something cloudy!
Tuesday, June 17, 2008
Using C# 3.0 in ASP.NET 2.0
C# 3.0 has a lot of great features to help with ASP.NET 3.5 web projects. However, you can also use SOME C# 3.0 features in SOME .NET 3.0 and 2.0 projects if you're using Visual Studio 2008. The gist of it is, if you create a new "ASP.NET Web Application" solution (File -> New -> Project... -> Web -> ASP.NET Web Application) you can use most C# 3.0 features (lambdas, vars, anonymous types, etc.) The exception being LINQ, expression trees and extension methods, which require additional classes/attributes that are only present in the 3.5 base class library. This works because the compiler is generating all of the code for your site into DLLs which have to be deployed along with your pages, and .NET 2.0, 3.0 and 3.5 all target the .NET 2.0 CLR.
However, if you are creating an "ASP.NET Web Site" solution (File -> New -> Web Site... -> ASP.NET Web Site), all bets are off. With this type of solution, you are relying on the framework to compile your application at run time. Thus, the target framework's C# compiler will be used. Because the C# 3.0 compiler is only available in .NET 3.5, you can not use C# 3.0 features with this feature of ASP.NET prior to v3.5.
There are a few ways around these limitations. First, you can use LinqBridge. LinqBridge recreates several of the classes from the 3.5 framework in the 2.0 framework, effectively letting you use nearly all C# 3.0 features in your .NET 2.0 projects. Expression trees are the only feature you won't be able to use. Extension methods, LINQ to Objects and query expressions all work just fine. However, you must be using the C# 3.0 compiler to use LinqBridge, so ASP.NET Web Site solutions are still left out in the cold.
Almost.
It turns out there is a sort of work around to compile an ASP.NET Web Site solution with C# 3.0, as long as you don't mind sacarificing dynamic compilation. From the Website menu, select "Start Options". Click on "Build". Change the Target Framework to 3.5 and clear the "Build Web site as part of solution" checkbox and click OK. Now click on "MSBuild Options" and set "Output Folder" to a path outside of your solution's source tree. I'd like to say I know why you have to do that, but I don't. You'll get an error from MSBUild if you specify an output folder within your solution's source tree. Boo. Hiss. Moving on. At this point, you will no longer be able to build your project in Visual Studio. However, you can build it with MSBuild. If you fire up a VS2008 command prompt, change to your web site solution's folder and type "msbuild", your project will compile with the C# 3.0 compiler. Please note that you are compiling your web site to DLLs, so you will not be able to make code updates. Still, it's potentially a nice interim solution until you can move your web projects over.
Here's a feature capability table:
However, if you are creating an "ASP.NET Web Site" solution (File -> New -> Web Site... -> ASP.NET Web Site), all bets are off. With this type of solution, you are relying on the framework to compile your application at run time. Thus, the target framework's C# compiler will be used. Because the C# 3.0 compiler is only available in .NET 3.5, you can not use C# 3.0 features with this feature of ASP.NET prior to v3.5.
There are a few ways around these limitations. First, you can use LinqBridge. LinqBridge recreates several of the classes from the 3.5 framework in the 2.0 framework, effectively letting you use nearly all C# 3.0 features in your .NET 2.0 projects. Expression trees are the only feature you won't be able to use. Extension methods, LINQ to Objects and query expressions all work just fine. However, you must be using the C# 3.0 compiler to use LinqBridge, so ASP.NET Web Site solutions are still left out in the cold.
Almost.
It turns out there is a sort of work around to compile an ASP.NET Web Site solution with C# 3.0, as long as you don't mind sacarificing dynamic compilation. From the Website menu, select "Start Options". Click on "Build". Change the Target Framework to 3.5 and clear the "Build Web site as part of solution" checkbox and click OK. Now click on "MSBuild Options" and set "Output Folder" to a path outside of your solution's source tree. I'd like to say I know why you have to do that, but I don't. You'll get an error from MSBUild if you specify an output folder within your solution's source tree. Boo. Hiss. Moving on. At this point, you will no longer be able to build your project in Visual Studio. However, you can build it with MSBuild. If you fire up a VS2008 command prompt, change to your web site solution's folder and type "msbuild", your project will compile with the C# 3.0 compiler. Please note that you are compiling your web site to DLLs, so you will not be able to make code updates. Still, it's potentially a nice interim solution until you can move your web projects over.
Here's a feature capability table:
| Solution Type | Project | Web Site | |||||
|---|---|---|---|---|---|---|---|
| .NET Framework Version | 3.5 | 3.0 | 2.0 | 2.0 with LinqBridge | 3.5 | 3.0 | 2.0 |
| Expression Trees | Y | N | N | N | Y | N | N |
| LINQ/Query Expressions | Y | N | N | Y | Y | N | N |
| Extension Methods | Y | N | N | Y | Y | N | N |
| Lambdas | Y | Y | Y | Y | Y | N | N |
| "var" keyword | Y | Y | Y | Y | Y | N | N |
| Anonymous Types | Y | Y | Y | Y | Y | N | N |
| Automatic Properties | Y | Y | Y | Y | Y | N | N |
| Object Initializers | Y | Y | Y | Y | Y | N | N |
| Collection Initializers | Y | Y | Y | Y | Y | N | N |
Sunday, May 25, 2008
Tuesday, May 20, 2008
How do you *know* it's a witch?
Wow.. The ALT.NET blogs have been downright hostile to the Entity Framework. Admittedly, I'm a total noob in this arena. I've done some work with IoC containers, but I haven't done much with the various and sundry ORM frameworks. I played around with Hibernate quite awhile ago and was very impressed (yes, I've written Java; no, it's not contagious), but NHibernate was in very early beta at the time.
Anyway. I think it's a bit premature to call for the pitchforks and torches with respect to the Entity Framework. From what I've read, the EF appears to force you to weld your code to it, which is annoying. But remember, this is 1.0 product and Microsoft has never, ever released a decent 1.0. I think it might be best to sit out this first version, but I wouldn't be surprised to see some interesting things coming from the mothership in the coming years.
What kinds of things? I'm glad you asked! The Entity Framework requires numerous XML files to work. Those XML files integrate seamlessly into C# and VB projects. In fact, Microsoft has a quite bit of history blending XML with their projects. So much so, that VB9 allows you to write XML directly in your code. C# doesn't have that feature (yet), but it does have LINQ. While LINQ isn't XML, it is a language in its own right. Then we have WPF, which comes in both XML and API flavors. Windows Workflow - same story. All of these things lead me to one conclusion:
Visual Studio will become a polyglot programming environment. I believe Microsoft is thinking beyond source code (the horror!) to an environment that allows us to write some code and literally draw other bits of code. Right now, it looks pretty ugly, but it should get better. The biggest flaw in my crystal ball is the fact that you can't mix .NET languages in a single project right now. Maybe multi-language source files are something we can expect in CLR 3.0? Imagine drawing data entities, writing utility classes in C#, contracts in IronRuby and orchestrating the whole thing with F#!
What a long, strange trip it will be.
Anyway. I think it's a bit premature to call for the pitchforks and torches with respect to the Entity Framework. From what I've read, the EF appears to force you to weld your code to it, which is annoying. But remember, this is 1.0 product and Microsoft has never, ever released a decent 1.0. I think it might be best to sit out this first version, but I wouldn't be surprised to see some interesting things coming from the mothership in the coming years.
What kinds of things? I'm glad you asked! The Entity Framework requires numerous XML files to work. Those XML files integrate seamlessly into C# and VB projects. In fact, Microsoft has a quite bit of history blending XML with their projects. So much so, that VB9 allows you to write XML directly in your code. C# doesn't have that feature (yet), but it does have LINQ. While LINQ isn't XML, it is a language in its own right. Then we have WPF, which comes in both XML and API flavors. Windows Workflow - same story. All of these things lead me to one conclusion:
Visual Studio will become a polyglot programming environment. I believe Microsoft is thinking beyond source code (the horror!) to an environment that allows us to write some code and literally draw other bits of code. Right now, it looks pretty ugly, but it should get better. The biggest flaw in my crystal ball is the fact that you can't mix .NET languages in a single project right now. Maybe multi-language source files are something we can expect in CLR 3.0? Imagine drawing data entities, writing utility classes in C#, contracts in IronRuby and orchestrating the whole thing with F#!
What a long, strange trip it will be.
Friday, May 9, 2008
The Best SATA/IDE-USB Adapter Ever
The Vantec CB-ISATAU2 adapter is marvelous! 99% of the time, I just want to hook up a drive and copy some data off of it. This normally means finding an appropriate enclosure, taking it apart, swapping out a drive, putting it together again and finally plugging it in and getting the data off of it. This adapter eliminates all but the last step. It has 2.5", 3.5" IDE and SATA connectors, a power connector and a USB connector. Plug in drive, plug in USB connector - done.
Buy one!
Buy one!
Sunday, May 4, 2008
Undermount sinks - awesome and sucky
All at the same time. It looks fantastic, but it's an unbelievable bear to install. It's no wonder people end up paying 30k-40k to have their kitchens updated - IT SUCKS! As nice as this sink is, I don't think I'd do it again. It's a sink. It doesn't need to look like a masterpiece, it needs to hold dirty dishes until I get them into the dishwasher. So next time, over-mount sink. I think that makes more sense anyway, with weight-loading and what-not.
Also, I got black caulk in my hair, which really pisses me off. Don't get me wrong - I'm sure a lot of people love black caulk, I'm just not one of them.
Oh well.. I'm just impressed I managed to drill 14 holes into the bottom of the countertop WITHOUT popping through the other side.
Here's a lovely piccy. Weekend over. Who needs a drink?
Also, I got black caulk in my hair, which really pisses me off. Don't get me wrong - I'm sure a lot of people love black caulk, I'm just not one of them.
Oh well.. I'm just impressed I managed to drill 14 holes into the bottom of the countertop WITHOUT popping through the other side.
Here's a lovely piccy. Weekend over. Who needs a drink?
Tuesday, April 29, 2008
Public Transit FTW
Today is the first day that I'm taking public transportation to/from work. It takes longer than driving, but it's LOADS cheaper. I'm leaving my car at work during the week so if I need it for anything while I'm at work, I'll have it. It takes about an hour on the train, so I'm going to try working, reading and blogging.
But right now, I'm listening to This American Life, which has me thoroughly distracted. It's about cryonics, which is both fascinating and frightening. It seems the first cryonics group was run by "some guy" and all of his scientific advisors quit early on. Quite an auspicious start...
Subscribe to:
Posts (Atom)


