Subscribe: Dotnet Fox
Added By: Feedage Forager Feedage Grade B rated
Language: English
ado  code  ctp  data  edm  end end  end  linq  microsoft  net  new  process  service  system  visual  windows  year 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Dotnet Fox

Dotnet Fox

Life, coding, and the elimination of curly braces

Updated: 2017-12-27T01:39:09.568-08:00


I've Moved...


I'm now posting on MSDN. Check it out here. Please update your RSS or ATOM feeds!!

EastBay.NET Launch Event -- TONIGHT


I'll be speaking tonight on WCF in Pleasanton (a.k.a "P-town") for the EastBay.NET UG's Vista launch event along with Deborah Kurata and David Klitzke. Bring your appetites for Vista, WPF and WCF presentations as well as REAL FOOD! Yes folks, we'll have dinner tonight from Erik's Deli. :-)

For more information check this out. See you there!

Upgrade your May CTP VB LINQ Samples to Orcas March CTP


If you are playing with LINQ in Visual Basic, you'll probably want to check out Jim Wooley's post on how to convert a VB LINQ project from the May 2006 LINQ CTP to the March 2007 Orcas CTP. The syntax has changed including the order of the Order By and Select clauses. Even though it may look weird to the SQL people, there is a good reason for it, actually. Putting the Order By clause fixes a scoping issue where you now don't have to select the fields you want to order by. There's also now no need to put a := for named parameters, you can use the more normal =. Anonymous types also have a new syntax. Better intellisense should help you out. Julie also has some good information as well so check her (I mean her blog) out.

Orcas March CTP Now Available


If you haven't seen it yet, here it is. VPC images and regular install packages are both available. (Though the specific feature list doesn't look like it's updated yet, you can read the overview.) A lot of things are finally coming together but I'm personally excited about LINQ. This CTP has the same features as the May LINQ CTP including LINQ to SQL and VB's XML literals. I'm off to download!......

VB WCF template in Visual Studio 2005 extensions for .NET Framework 3.0


Just an FYI to anyone that is playing with WCF 2005 extensions in Visual Basic. When you create a WCF Service Library in VB, the code for the DataContract1 class it provides does not have attributes on the properties FirstName and LastName, so when you try to generate a proxy it doesn't generate correctly and the sample doesn't work. New Project --> pick template VB/.NET Framework 3.0/WCF Service Library You'll see that the code for the DataContract1 at the bottom of the file doesn't have any attributes. This has been fixed in the Orcas CTP that's due out very soon. So for now just pop those attributes in there and then follow the rest of the directions in the template to set up a host and config files. _ Public Class DataContract1 Private m_firstName As String Private m_lastName As String _ Public Property FirstName() As String Get Return m_firstName End Get Set(ByVal value As String) m_firstName = value End Set End Property _ Public Property LastName() As String Get Return m_lastName End Get Set(ByVal value As String) m_lastName = value End Set End Property End Class The template doesn't tell you directly how to set up a client to call it, but there is a VB example that shows you how. It's provided in the Program Files\Microsoft SDKs\Windows\6.0\Samples\ then extract the and locate the \TechnologySamples\Basic\GettingStarted\VB\GetingStarted.sln. Here you can see a sample client and how to add the proper MetaData Exchange (mex) endpoint and service behavior so that you can generate the service proxy on the client side using "Add Service Reference" from the project menu. If you're following the instructions in the template, to add the endpoint to the host console application you need to put this in your app.config (note, if your host is a web server then you will place this in the web.config): Then start the service (this is important) and in your client select from the project menu "Add Service Reference" and put the MetaData Exchange endpoint as the service URI and it will generate the client code for you with no problems. [...]

How to check the executing Type from the base class


Occasionally when designing base classes we need to know the type of the inheriting class executing the method (i.e. like when you're loading types from other assemblies dynamically or when it's not possible to change the inherited classes). You can either use the TypeOf operator in VB or use the GetType method that is available in the CLR to accomplish this.

Module Module1
    Sub Main()
        Dim a As New A
        Dim b As New B
        Dim c As New C
    End Sub
End Module
Public MustInherit Class Base
    Function Method1() As String

        If TypeOf Me Is A Then
            Return "Hello from A"

        ElseIf TypeOf Me Is B Then
            Return "Hello from B"

            Return String.Format("Hello from {0}", Me.GetType.ToString)
        End If

    End Function
End Class

Public Class A
    Inherits Base

End Class

Public Class B
    Inherits Base

End Class

Public Class C
    Inherits Base

End Class

SOA Facts


One of my favorite sites on the web is a Chuck Norris fact site. If you've never seen it it's hilarious. Well they now have SOA facts which is equally amusing. Enjoy!

Sync Services for ADO.NET


If you haven't seen it yet, the Sync Services CTP was released a couple weeks ago. Today they released the documentation and samples. The sync services for ADO.NET enable you to develop occasionally connected clients much much easier. The sync framework provides easy detection of all the types of data concurrency and conflict handling issues you encounter when developing offline clients and makes it easy to code resolutions. Best of all it uses SQLce and the deploymemt package is under 2Meg. For more information see Steve's and Rafik's blogs.

BTW, I'll be speaking at DevTeach in May on the sync services and architectures of occasionally connected clients.



In doing some more research on ADO.NET's Entity Data Model (EDM) I came across some videos here and here by Shyam Pather, Dev Lead on the ADO.NET Team. The videos are from last summer but they do a really great job of describing the EDM as a conceptual model of your data, describing properties, associations/relationships, even inheritance -- using much a richer type system to model the entities. It separates the actual normalized data schema away from your application so that when underlying schema changes happen, your application is safe as long as the entity model hasn't changed. With ADO.NET 3.0 you can write queries (with a new 'entity SQL' eSQL query syntax) against the EDM and the data access stack automatically translates them to the database -- instead of getting rows back you get entities. Of course, any changes you make can be tracked and persisted back to the database automatically for you as well.

What I really love about the ADO.NET team is that they pay attention to the backward compatibility and migration issues. What I like here is the easy migration path of current code by using the new Mapping Provider (instead of the Sql Provider). The provider is different but the key is that you can use the connections, commands, readers, etc. in the same manner as you are accustomed to. However if you are writing new code you can create a strongly-typed query using the new Query class that returns the objects instead.

This is all really really really great, however, I'm not too jazzed about learning yet another query syntax just to query these entities. Here's where LINQ comes in. You can query the EDM directly with LINQ, (very similar to how DLinq looks, actually). Let's take a couple examples. Here's how you would access data today:

Using cnn As New SqlConnection(MyConnectionString)
    Using cmd As SqlCommand = cnn.CreateCommand()
        cmd.CommandText = "SELECT Employee.Name, Region.Name " & _
                "FROM SalesPeople " & _
                "INNER JOIN Employees ON SalesPeople.EmployeeId = Employees.EmployeeId " & _
                "INNER JOIN Region ON SalesPeople.RegionId = Region.RegionId"

        Using dr As SqlDataReader = cmd.ExecuteReader()
            'Process DataReader.....
        End Using
    End Using
End Using

Say I created an EDM with an entity called SalesPeople, here's what the query could look like using Entity SQL (eSQL):
Using cnn As New MapConnection(MyConnectionString)
    Using cmd As MapCommand = cnn.CreateCommand()
        cmd.CommandText = "SELECT Name, Region FROM SalesPeople"

        Using dr As IDataReader = cmd.ExecuteReader()
            'Process DataReader.....
        End Using
    End Using
End Using

Finally (using the same EDM) here's what it could look like with LINQ:
Using edm as New MyModel()
    Dim sales = From s In edm.SalesPeople Select s
    For Each person As SalesPerson In sales
        'Do something with the SalesPerson objects

End Using

All this makes me think... why do we need DLinq (LINQ to SQL) at all? Hmmmmmmm????? Seriously.

The History and Future of ADO


If you haven't seen it, Mike Pizzo, an Architect for Data Programmabilty at Microsoft, has a series of blog posts describing the interesting history and evolution of ADO into what it is today.

In his last post he describes the Entity Data Model (EDM) and how client views are exposed through an ADO.NET data provider extended to support a query tree representation. He also explains what happened to ObjectSpaces, which I found particularly interesting. He goes on explaining how LINQ is supported in the Entity Framework (ADO vNext) and that they both will be featured together in the next Orcas CTP (due in Feb/March). One thing that I asked Mike is what kind of guidance can he give on using EDM over DLinq and when we can see tooling for EDM in Visual Studio.

This next Orcas CTP is very exciting because it will have all the pieces finally together. LINQ, ADO vNext, and WPF tooling are my personal interests.

Relaxed Delegates in Visual Basic 8


Maurice posted a workaround for relaxed delegates in Visual Basic 8. Relaxed delegates are described in the Visual Basic 9 Overview on MSDN.

Ready for a New Day?


I attended the Vista Launch event at Moscone Center in SF on Tuesday. It was a large event but nothing compared to the Visual Studio 2005 launch that was here back in November 2005. The first debacle of the day was that the event details and announcements all pointed you to Moscone West (same building where the VS launch was held) but it turned out the doors were locked and not even one poster was on the wall inside. I was standing around with a few other scratching heads thinking "Where's the 'Wow'?" Finally a guard came to the window and told us the event was taking place in Moscone North. So all morning you had large groups of nerds walking across 4th street over to the Moscone North entrance. The main launch for Vista was in New York City and looked huge but in SF they still had both Moscone North and South halls dedicated to three separate IT Pro tracks, one Developer track and one Decision Maker track. I helped out with the Ask the Experts area and in between that I popped into a couple sessions on the Developer track. SF wasn't cool enough to get BillG or Balmer for the keynote, instead it was done by Jeff Raikes, President Microsoft Business Division. He presented a lot of business cases for moving to Vista and had people demo the new OS as well as Office 2007 showcasing the new task oriented interfaces. My personal high point of the keynote was when he introduced the CEO of Sierra Nevada Brewing Company to discuss how Vista has made his QA department more productive (so that they can drink more beer, of course). Among the local developer evangelists and Microsoft presenters, Juval Lowy, Deborah Kurata, Scott Stanfield also presented the new technologies in Fx 3.0, giving demos on Windows Presentation Foundation, Windows Communication Foundation and Windows Workflow Foundation. I also caught Nima Dilmaghani (local evangelist and all around nice guy) presenting on the new SharePoint integration. All in all it was an informative track for developers to get a taste of what is possible with Windows Vista and Office 2007. I assume it was equally beneficial for the IT pros (comments anyone?). I recommend attending a launch in your area. [UPDATE: I forgot to mention for filling out session evaluations, attendees received a free copy of Office 2007. So if anything else, it's worth it to attend just for that.][...]

I've Been Tagged! Five things about me....


Okay, I suppose I can't ignore this anymore since both Markus and Sam tagged me this week. It was only inevitable I suppose. Okay so here it goes -- five things you didn't know about me.

1. I'm a car fanatic and I have a 2003 Subaru WRX-ESX Stage 4 built by EasyStreet and Gruppe-S. Once in a while I race it at Sacramento Raceway. It does a 12.7 quarter mile. Next project is a rear swaybar, endlinks and a new clutch :-)

2. I used to race mountain bikes, now I just ride them. I have a 2003 Specialized FSR-Disc. I love to ride many of the thousands of miles of trails on Mt. Diablo. We have a beautiful view of the mountian from our bedroom.

3. I have an XBox 360 and I am addicted to any car/motorcycle games. I play almost every night if I'm not watching Battlestar Galactica DVDs. We just got my dad who's retired an XBox 360 for Christmas so I'm hoping he sets it up and gets his online profile so I can kick his butt.

4. I love wine and beer to the point where we're considering building a wine cellar. Exposure to great wines is easy living in the Bay Area. We go to festivals once or twice a month, even in the winter. This weekend we're headed to the 15th Annual Winter Wineland. I also belong to World Beer Direct's Beer of the Month Club where they send me three bottles each of two different international beers and two different American microbrews to my door every month.

5. I'm a pro Baseball and Football fan (it goes well with the beer :-)). I'll watch college football this time of year for the bowl games (Holy Crap, Boise State!). We have season tickets to the Oakland A's and we're considering going to spring training in phoenix this year. I'm an Oakland Raider fan too but that's a little bit embarrassing to say right now! I've been a Raider fan since they won the 1984 superbowl when I was 12 years old. My family lived in the Los Angeles area (San Pedro) back then.

Okay now for the lucky winners who get tagged by me!

- Rod Paddock
- Duffy
- Eric Newcomer
- Bill McCarthy

Visual Studio 2005 SP1 Released


Get it here!

Explicit Impersonation and Async Thread Identity in ASP.NET


I've been doing some asynchronous thread programming in our server components and last night ran into a gotcha that took me a few hours to figure out so I thought I'd post this one to save people some trouble. I've implemented a Fire and Forget asynchronous pattern similar to Mike Woodring's sample so that I could execute longer running processes than the typical web request on a spearate thread and return back to the client immediately. These processes connect to a SQL database using windows integrated security. All was working just dandy on my development XP box running without impersonation. In this scenario the components run under the default ASPNET identity and connect to a local database. (In Windows 2003/IIS6 the default identity is NETWORK SERVICE.) However when I went to deploy it on our testing servers I ran into a problem with the asynchronous thread identities. They were throwing exceptions trying to connect to the database. Our test rig is set up as two Windows 2003 servers, one app server and one database server on their own little domain. We set the app server's web.config with explicit impersonation of a least priveledged domain account that is windows authenticated to the database. All works fine for client request threads, however the identity of the async threads were that of the application pool, not the explicit domain user and was therefore causing problems connecting to the database. I figured I could change the application pool identity, but I wasn't satisfied with having to remember another configuration setting. I really wanted the Web.config to be the only place for this and I was perplexed as to why the main thread's identity wasn't getting propagated. I still am not sure as to why this is the case since the documentation for ThreadPool.QueueUserWorkItem makes it seem like this should work in .NET 2.0. I ended up augmenting the AsynHelper class to impersonate a WindowsIdentity. Here's the code and it's usage (comments/suggestions welcome!): Imports System.Threading Imports System.Security Friend Class AsyncHelper Private Shared wc As New WaitCallback(AddressOf CallMethod) Public Shared Sub FireAndForget(ByVal d As [Delegate], _ ByVal wi As Principal.WindowsIdentity, _ ByVal ParamArray args As Object()) ThreadPool.QueueUserWorkItem(wc, New TargetInfo(d, args, wi)) End Sub Private Shared Sub CallMethod(ByVal o As Object) Dim ti As TargetInfo = DirectCast(o, TargetInfo) 'This is necessary so this thread impersonates the 'calling thread's identity. This is important when 'running under ASP.NET explicit impersonation. ti.Identity.Impersonate() 'Invoke the method, passing the arguments ti.Target.DynamicInvoke(ti.Args) End Sub Private Class TargetInfo Private m_target As [Delegate] Private m_args As Object() Private m_wi As Principal.WindowsIdentity ReadOnly Property Target() As [Delegate] Get Return m_target End Get End Property ReadOnly Property Args() As Object() Get Return m_args End Get End Property ReadOnly Property Identity() As Principal.WindowsIdentity Get Return m_wi End Get End Property Sub New(ByVal d As [Delegate], _ ByVal args As Object(), _ ByVal wi As Principal.WindowsIdentity) m_target = d m_args = args m_wi = wi End Sub End Class End Class And here's a usage example: Private Delegate Sub ExecuteQueryD[...]

Linq's the Word


Many thanks to all those who came out on Thursday to play with the latest Linq CTP at the East Bay.NET User's Group in Pleasanton! Here's the link to all the presentation code.

The presentation went really well and the samples sparked a lot of discussion and interest with the group who had never seen language integrated query. Most of the attendees were very excited and anxious for it to release, as am I.

Linq changes the way you think about solving problems in your code. That coupled with Visual Basic's dynamic interfaces and XML literals you definately have the most flexible language I have ever seen. Read here for an overview of these features coming in the next version.

Bay.NET UG presentation code


Many thanks to all those who came out on Tuesday to see me speak at the Bay.NET User's Group in San Fransisco! Those of you who missed it, I did a more in-depth presentation of the Data Sources and Data Binding in VS2005 session that I gave at DevTeach. Here's the link to all the presentation code. Have Fun!

Debugging Windows Services in Visual Studio


Last week I started writing a Windows Service in Visual Studio for some build and test automation programs. What I have always found annoying (but understandable) about windows services is the debugging. Because your code is set up to run as a service when you select the Windows Service template in VS that means you have to install the service, start it, and then attach to the process in the debugger instead of being able to click the "start debugging" button on the debugger toolbar like I'm used to with other project types.

Previously, I followed the advice in this article by creating a setup program that easily allowed me to install and uninstall the service directly from the Solution Explorer in VS. However I still have to either call System.Diagnostics.Debugger.Break() in my code (and remember to remove it when I'm done!) or attach to the process in order to debug it.

There's an easier way. If you look in the Main entry point of the service you will see how the service is loaded. (In C# this is in the Program.cs file that's created for you and in VB.NET this code resides in the service's Designer.vb file.) You can modify this code by adding a DEBUG compiler directive to control how the process starts:
    <MTAThread()> _
    Shared Sub Main()
#If DEBUG Then
        ' Start the process as a non-service for debugging only.
        ' Stop the debugger to stop the process.

        Dim service As New MyService 

        Dim ServicesToRun() As System.ServiceProcess.ServiceBase

        ' More than one NT Service may run within the same process. To add
        ' another service to this process, change the following line to
        ' create a second service object. For example,
        '   ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
        ServicesToRun = New System.ServiceProcess.ServiceBase() {New MyService}

#End If
    End Sub
Now when your configuration is set to debug, you can hit F5 to debug like normal. Stop the debugger to stop the process. Keep in mind that the OnStart and OnStop methods of your service will not run so you should break your functionality into a callable method on your service class (in this example, I called it "Execute()"). Have fun!

Programming Computers


Today I spoke to some of my mom's computer students about programming at the school where she teaches. What a change from last week where I'm teaching other developers advanced programming topics at DevTeach. Today I'm encouraging 14 year olds to get into the field and demo-ing Visual Basic 2005 Express and the starter kits. We had a blast poking around the black jack starter kit. I started the presentation by introducing myself and telling them the kind of software products we write at GiftRAP Corporation. I told them that I worked at Microsoft a couple years ago on the Visual FoxPro team in the developer division. Then I explained what a Microsoft MVP is and that I still get to contribute ideas to Microsoft even though I don't work there. Since I wanted to encourage them to start programming, I went through some of my history as a kid learning to program. I showed them my first computer, the Atari 400, and my first programming language; it was 1980 and I was 8 years old. I got some bright eyes in a couple kids when I said that. I got some gasps when I told them it retailed for $595.00. I realize now that my parents really sacrificed to buy that computer for me; they didn't spend that type of money back then. Then I skipped to 1986, the year I was in 8th grade and showed them the Amiga 2000 HD. I think HD meant that you got a hard drive, something I didn't have on my Franklin "IBM PC clone". I wanted to draw all day when I was a young teen but I loved computers, so I begged my mom for an Amiga; the best in computer graphics at the time. And as a bonus, it came with an 8086 motherboard so I could run MS-BASIC. With 1MB RAM I was cooking with gas. Finally I showed them a picture of a few of the machines I have today including my 2 year old SmartPhone. I waved it in the air and told them it had 32 times more memory than my Amiga 2000. A couple kids laughed and a couple wanted me to cut to the chase -- let's program already! I opened up VS and selected the card game starter kit template and we started tweaking it. I changed the card skins to a snoopy face and made Player 1 a picture of the president. They laughed, they stared, they asked questions. I'd say they seemed pretty darn interested (for teenagers). I pointed them to a VS Express Edition game programming site that looked pretty fun. I think I proved to them that programming is not only a scientific process but also a creative one. Mom said to save the presentation and she wants me back earlier in the year next year. I'm really glad I had the opportunity to do this with the kids today, it's almost harder to do these types of lessons than the professional sessions I do. It's cool, I think some things I was saying to them sunk in and hopefully will make a tiny impression on their future career choices. It was a very rewarding talk for me. Here's the links I gave them. This is VB Express free edition: These are the starter kits: Here's the sweepstakes and more games: Links to beginer videos and learning links: Here's the community forum:[...]

"Best and Worst of .NET" Interviews at DevTeach


Mario Cardinal interviewed the speakers at DevTeach on what we thought were the best and worst parts of Microsoft .NET. Mario snuck up on me and put me on the spot. If he asked me again today I would probably have thought of completely different things to say. There's just so much I like ;-). Check it out here!

Amazing Countrysides


So now that DevTeach is over, Alan and I are in beautiful Vermont staying with Julie Lerman and her husband Rich. What a great feel this countryside has, rolling green hills and birch trees everywhere. Living in the East Bay Area of California we have lots of rolling green hills but the grass is very different; much longer, and dies in the summer. We also have oak trees, not these white wood birch so it's so cool to see a different countryside. (Although all this birch is a little Blair Witch-y for me at night ;-P) It's my first time in Vermont but I'm sure I'll be back.

Wonderful Montreal in May


DevTeach is over; what a great time! Montreal was absolutely beautiful. No rain, nice and warm, in the 70s. I couldn't have asked for anything more. My sessions went very well and I got great feedback from the attendees on the conference as a whole. For session coverage check out the UT. The focus was on Data and Alan gave a great keynote on LINQ. If you haven't done it already, download the latest CTP and start playing with it now. It really will change the way you program... everything.

Another MVP year!


Yahooo! I was awarded Microsoft Solutions Architecture MVP again this year. Thanks to everyone involved over at Microsoft and to all the readers of my blog in this awesome community. Hope to see you all next month in Montreal!

The best definition of software architecture I've heard


My friend and fellow Architect MVP, Eric Newcomer mentioned in a blog post something I said when we were having dinner last week in SF and it ended up in SOA Web Services Journal. I'm glad all my ranting pays off once in a while ;-).

I'm speaking at DevTeach 2006


I'm speaking again this year at DevTeach 2006 in Montreal May 8th-12th.

I'm doing three sessions this year, one called "VS2005 Data Sources and Data Binding" and a two part session on "Designing Applications for Multiple Smart Client UIs". That one also demonstrates a server architecture that supports windows clients as well as mobile devices against the same centralized data. We'll also discuss occasionally connected scenarios and architecture options we have today and in the future. You can see all the speakers and sessions listed here. Hope you can make it!