C#
Instead of having our regularly scheduled IADNUG meeting, we're having Mike Benkovich and Kent Tegels do an MSDN Unleashed Event at DMACC West! Here's the info on it:
Join us at our MSDN Unleashed events for the latest tips, tools and technical information you need to build powerful applications and engaging user experiences. We'll show you how SQL Server 2008 delivers new development capabilities, including support for Spatial Data types, a fresh storage mechanism and more. You'll also learn how to leverage the Silverlight platform to build next generation applications for consumers and business. Don't miss these free, live sessions near...
Can't make it to the Professional Developer's Conference (PDC) in LA? Well, we've started a new group called NotAtPDC! Chris Love is the genious behind this movement! Here's some info from him:
We are going to have live meeting sessions, links to Blogs, Podcasts and any other .NET related content featured this week. Right now we are trying to get things organized better. We will have a site live in the morning. If you want to schedule a session or something DM http://twitter.com/NotAtPDC.
Chris is in the process on getting a website up to aggregate some of the content that the...
A couple of weeks back, I recorded a podcast with, our community MS Developer Evangelist, Jeff Brand for his Spaghetti Code series. I was informed by Jeff, today that he finally posted it! I had a heck of a time recording this podcast with Jeff, the hour just flew by! If yo have the time, download the podcast and check it out!
Links:
Direct Download - click here
Subscribe - click here
iTunes - click here
So, here's a little shameless self plug for a book that Bryan Sampica and I are writing...also, I'm using this blog post as a warm up for my writing this evening! Yes, like I just mentioned, I'm co-authoring a book for Wrox with Bryan entitled, ASP.NET 3.5 Programmer's Reference. The purpose of the book is to get you the novice/beginner introduced to the features of ASP.NET 3.5, and hopefully teach you a few tricks things along the way. The book is due out in November, so that means that my summer (evenings) is pretty much booked up. I must...
For those of you that attended my Silverlight presentation yesterday at the Twin Cities Code Camp, I just want to say, "Thanks for coming! I hope you enjoyed it!" As promised, you can download the presentation slides and source code from Google code using TortoiseSVN. Again, thanks for coming to my presentation and thanks to Jason Bock for allowing me to come up and be part of a great event!
That's right! We're having another ASP.NET Expert Live Chat on Thursday, May 1st, 2008 at 6 PM PST. Here's more info on the event: Get your tough development questions answered by Microsoft MVPs, Regional Directors, and other industry experts. Community experts will be on hand to answer your .NET- and Visual Studio-related questions. No off topic questions please. Please note that questions regarding upcoming products and future product specs might not be answered. Would you like to participate as an expert? Contact Ryan Olshan at Ryan[dot]Olshan[at]strongtypes[dot]com. MSDN Online Chats - http://msdn2.microsoft.com/en-us/chats/default.aspx Chat Room...
As you recall, we cancelled last month's UG meeting due to weather. For this month, we're having Bryan Sampica, an ASP.NET MVP from Cedar Falls, come talk to us about WPF! The info for the meeting is below. Hope to see you there! Utilizing WPF as a Business Application Platform Bryan Sampica, ASI Computer Systems With the emergence of WPF and XAML as a UI framework, we've seen lots of demo's and examples on animating birds, and playing video clips. In this session we'll examine the business...
Wow! I stumbled into this "blast from the past" the other day, I just had to share it with you. Here's the background story...
A couple of years ago, I encountered some source for a C# compiler written in pure C# by Mike Stall. I downloaded the source and started messing around with it seeing how it worked. At around the same time, I had a conversation with Nick about how English is the dominant language for technology and that most (if not all) programming languages are written in English. Granted, this is a good thing since it establishes a convention...
Thanks to Mitchel Sellers from IowaComputerGurus for presenting to our user group last night! We had a pretty great turn out and some really nice swag to give away! For those of you that were there, thanks for your support! As I mentioned during the meeting, we're going to try something a little different for distributing demo materials (code, ppts, etc.). I've setup a iadnug, a Google Code open source project, to host our code. (yeah, clever name I know...) So for those of you that have SVN or TortoiseSVN installed, you can check out the code. If you...
Well, we can finally get our hands on the ASP.NET MVC bits! They're being released as part of the ASP.NET 3.5 Extensions CTP. This release includes: ASP.NET AJAX Improvements: New ASP.NET AJAX features in the ASP.NET 3.5 Extensions release include better browser history support (back/forward button integration, and server-side history management support), improved AJAX content linking support with permalinks, and additional JavaScript library improvements. ASP.NET MVC: This model view controller (MVC) framework for ASP.NET provides a structured model that enables a clear separation of concerns within web applications, and makes...
That's right, PDC has been rescheduled to Oct. 27-30 2008 in Los Angeles, California. Here's the info from their site: PDC 2008 October 27–30, 2008 Pre-conference October 26, 2008 Los Angeles, California OK, OK. We are delighted to announce the date and location of the next Microsoft Professional Developers Conference (PDC): October 27–30, 2008 at the Los Angeles Convention Center. PDC is the definitive Microsoft event for software developers and architects focused on the future of the Microsoft platform. Mark your...
Well, as I previously blogged about it, the details are done for our demo contest during the VS2008 InstallFest in Des Moines are finalized. Here they are: Visual Studio 2008 Demo Contest! Want to show off your VS2008 or .NET 3.5 skills? If you answered, yes, this is your opportunity to strut your stuff! During the Visual Studio 2008 InstallFest & Holiday Party on December 12, 2007 at the DMACC West Campus, we'll be having a demo contest in the auditorium. Here's the scoop ... What do I need to...
That's right, the InstallFest event in Des Moines has SOLD OUT! As of today, there are 13 people on the waiting list. For all of you that signed up, thanks! It is because of you that this event will be a success! Also, if you're interested, you should sign up to do a demo during the event! Those of you on the waiting list, you will be notified of an open spot if someone on the main list cancels. So if you're on the main list but can't make it, please cancel so somebody on the waiting list can...
That's right, you can now download the Silverlight 1.1 Tools Alpha for Visual Studio 2008 RTM. Get it while it's hot!! One thing to notice is that this release does not work with the Express Editions.
First, to all of you that attended my HDC presentation on Software Factories, THANK YOU! I hope that as promised, the "Ah, Ha!" factor was high. Also, I would like to apologize for the issues I ran into with the VPC and the demos. I had tried the demo before with only two VS2005 instances running and had no issues with it...Apparently, four instances of VS2005 running concurrently is too much for VPC. Right after my presentation, I confirmed with Steve Loethen, a co-host of Code To Live, about coming up with the webcast series on Software Factories. I still to work out...
That's right, you heard it! Scott Guthrie and Scott Hanselman have both talked about it (Scott even has a podcast on it). Microsoft will release the source code & debug symbols for debugging purposes for the following .NET libraries under the Microsoft Reference License (MS-RL):
Base Class Libraries
ASP.NET
Windows Forms
ADO.NET
XML
WPF
They plan on adding more libraries in the months to come, such as WCF, Workflow, LINQ.
I'm not sure about you, but this IS HUGE! Way to go, MS! Taking...
Dave Bost, DE for IL, IN, WI and former golfing partner, invited me through Facebook to the SilverlightDevCamp in Chicago, IL. For those of you in the area or interested in attending this FR-EE event, here's the info from Dave's blog post:
On Friday, September 28th and Saturday, September 29th, Clarity Consulting will host a Silverlight DevCamp at their offices in the Loop. This is a great opportunity for people interested in Silverlight to come together and hack out an application or two.
DevCamps are similar to BarCamps in that it’s a casual gathering of like minded individuals. BarCamps tend...
A while back, I blogged some examples on how you can use .NET types within your IronRuby (IRuby) applications. So after playing around with it a bit, I wanted to do something pretty basic, inheritance. Here's what I tried:# Basic inheritance from a dynamic type
# to a static type.
class MyForm < System::Windows::Forms::Form
end
When you try running this through the interactive console, you get this error:
System.InvalidOperationException: superclass must be a Class (DynamicType given)
Nice and descriptive, huh? Well, essentially this means that your superclass needs to be a type that IRuby can understand, that is a class-type of DynamicType. While looking around at the source...
Anybody? Let's start this conversation and see where it goes? David, I'm really interested on what you have to say about this!
Looks like Nick has also posted his findings on IronRuby ... what can I say, it was just released today!! Anyway...I was playing around with IronRuby earlier this evening trying to see how it handled generics...well, currently it doesn't (remember, the code is alpha...but pretty sweet!). I created a sample C# class (cleverly) called, MyClass:using System;
namespace CSharpClass
{
public class MyClass
{
// Currently this event type cannot be called from IronRuby.
public EventHandler<CustomArgs> Custom;
...
That's right, John Lam and ScottGu have blogged about it! So go get it while it's hot!!! THIS IS SOO FREAKIN' COOL!!!
Ok, so I'm really, really, really stupid! I like other people out there suffer from the always popular I-have-too-many-passwords (IH2MP) syndrome. Earlier this past weekend, I was trying to administer my blog and managed to forget the editor password so I could access the website. After several failed attempts, I searched the application folders of Windows Live Writer to see where my password was kept. It appears that by default, Live Writer stores its configuration information under the registry. To retrieve the configuration information correctly, you need to use their API. Here's a sample on how you can accomplish this:using...
Well, it looks like Nick and Jeff have beat me to the punch of announcing ReSharper 3.0. For you VB.NET-ers our there, GET THIS TOOL! OMG, it's the sweetest thing that ever happened to VB since .NET!!
That's right, I received word from Phil Wolfe earlier this week that I've been accepted to be a speaker (this is my third year!) for the Heartland Developer Conference in Omaha, NE on Oct. 18-19th. If you check out the speakers page, you won't see my info there but I'm sure it's coming. For those of you that like my presentations, here's a list of topics I've been kicking around: .NET Tooling for Oracle - There's some applications out there that need talk with Oracle. How do I make things as easily as possible to get my work done?...
Yesterday, Levi sent me a link to this add-in for Reflector that disassembles a Silverlight applications and shows your the JavaScript to run it. I must say, it's a pretty nice little add-in (that includes its source) for Reflector. Below is a picture of the disassembled Silverlight Airlines demo given at MIX '07:
Check it out if you have the time, it's pretty sweet!
From the looks of it (via Phil Haack), CodePlex will be supporting SVN (both svn.exe and TortoiseSVN) for all of their projects. Here's the converstaion Jim Newkirk and Phil had: Haacked wrote Mon at 8:24 PM So I can download svn.exe from http://subversion.tigris.org/ and manage my CodePlex source code repository, yes? So are you rolling out Subversion? Or a Subversion facade into TFS? Anything you can reveal? :) jimnewkirk wrote Mon at 7:41 PM To clarify: it's our intention to support the functionality of the command-line Subversion client as well as TortoiseSVN. jimnewkirk wrote Mon at 7:40 PM Phil,...
Ok, so I've just posted my current non-technical reading list so now here's my techinical currently-reading list:
Programming Ruby: The Pragmatic Programmers' Guide, Second Edition - Dave Thomas, Chad Fowler and Andy Hunt
I've been playing around with Ruby for quite some time now but I need a good reference book for it. What other book to read than main source of Ruby knowledge out there! After the announcement of the DLR (which I've downloaded already), I can't wait to do more of Ruby natively on .NET!
Programming WCF Services - Juval Lowy
Another great master work by Juval. If you're currently doing WCF...
Alright, so for our applications we have a couple of forms that use the DataGridView control to display tabular data (kinda of a common scenario for many business applications). The data is returned from our services as an IList<T> in which we can just then bind directly to the grid by using the grid's DataSource property. Pretty easy task...unless when it comes to sorting. From the looks of it, Ayende has the similar problem that he's trying to overcome... At that point, our IList<T> doesn't cut it. You could say, well, use an BindlingList<T> and override the ApplySortCore...
Wow, it appears that "WPF/E" has a better RTM name than the other W*F parts. That's right, "WPF/E" is now called Silverlight (via Soma's blog). Also, don't let the name confuse you, if you have already the "WPF/E" Feb CTP, you already have Silverlight installed. They've just renamed the install packages.
That's right, we're at it again! We're signed up to answer your ASP.NET related questions for two hours on April 19th at 11:30 PST (1:30 CST).
The chat format is as follows: You post your questions and the panel of experts answers them. We're using the Microsoft Chat Software (MVP’s only, sorry!) to grab questions and answer them. The first chat did not have this software working well and was kind of chaotic (MSN Messenger & Conference Call). The software is now working, so it should be a very smooth flow of questions and answers. We're still doing the conference call so that when...
That's right! ScottGu has blogged about a new hot fix (Microsoft KB #934839). I've ran into this problem in the past (and blogged about it here). Scott posted a quick fix you can use without installing the patch: <configuration> <system.web> <compilation debug="false" batch="false"></compilation> </system.web></configuration> I'm glad to see an official fix being released after a year since the issue emerged.
I've been meaning to blog about this for a while, but for some reason I keep forgetting (sorry, I've been busy at work). If you're wondering on how WCF compares performance wise to existing distributed communication technologies (ASMX, WSE, Enterprise Services, .NET Remoting) you should definitely check out this white paper on MSDN: A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies
I know this is old news, but I'm extatic that Microsoft has acquired DevBiz and consequently, TeamPlain for TFS. You can read more about it over at Brian Harry's blog. Back when I was evaluating TFS for work, I installed TeamPlain and was pretty amazed what the application did. Back then, the licensing was ~$100 per client, but now that MS has acquired it, it's now FR-EE!! Check out the screen shot below to see TeamPlain's coolness:
So, a couple of days ago while sitting at the lobby of my hotel for the MVP Summit, I decided to come up with a simple Smart Client shell for the LOB Windows application my company uses. So there I am minding my own business when along comes Jean-Paul Boodhoo, James Kovacs, David Laribee, DonXML and ask what I was working on. After some explaining of my intentions for replacing our legacy VB6 application with a brand new .NET one, JP couldn't resist the opportunity to do some TDD and Pair Programming. I must say, that I've always been of the...
I would like to thank Paul Sheriff for taking the time to speak to our user group. He did an excellent job on presenting an intro to OOP. In case you were not there, he has offered a free eBook for our UG members. Go here, to get it. Once again, thanks Paul!
Thanks all that attended my CRINETA presentation Applied .NET 2.0 Programming! I'm pretty impressed on the level of interaction we had throughout the presentation. To me, this is what made it really memorable for me! Once again, thanks for attending!
That's right, on Monday March 5th, I will be presenting for the Cedar Rapids .NET User Group about .NET 2.0 programming. Here's the info: Applied .NET 2.0 Programming Are you tired of the same old boring "collection demos" for generics? Ever wondered how anonymous delegates really work? Tired of playing with System.Xml clasess to a grip of your .config file? Or how about adding basic transaction support to common .NET types? In this session I will show you how you can take some of the new features of the .NET Framework 2.0, (Generics, Anonymous Delegates, Configuration, and Transactions) and apply them to your current development with minimal...
By the way, I posted about this chat a while back....
but if you don't recall and are free tonight from 7-8 PM CST (8-9 PM EST, 5-6 PM West Coast Time), come check out our ASP.NET MVP Public Chat! Check out the line-up of MVPs that are ready to answer your ASP.NET questions!
You can join the chat by going to the MSDN Chat Center.
PluralSight's own Fritz Onion will hosting 8 ASP.NET webcasts next week. If you're interested in checkin them out, you can register here.
Not sure if any of you out there knew about the RSS toolkit for ASP.NET. Dmitry Robsman created it a while back and now IDisposable has put it out on CodePlex. If you're doing any work with RSS on ASP.NET, check out this toolkit! It will greatly simplify what you're doing.
Just wanted to wish my readers (both old and new) a happy new year! I'm sorry I haven't had the chance to blog more but I've been quite busy at work. I've been doing a lot of working with interop with VB6 and VB.NET. I've also added some MVP and WCF to spice things up as we slowly scale and re-write our application. My main task it to finish my Extending ASP.NET article series on Code Project.
I'm planning to have a couple of C# “syntactic sugar” posts. While working on our framework at work, I'm been using some of new features of C# 2.0 that help...
That's right, it's out! Microsoft has released SP1 for Visual Studio 2005, Team Foundation Server, Express Editions and Vista Beta. Here's some info from Microsoft: Visual Studio 2005 Service Pack 1 continues Microsoft’s investment in market leading development tools. Service Pack 1 addresses issues that were found through a combination of customers and partner feedback, as well as internal testing. The issues addressed range in severity from places where the syntax coloring was incorrect to customer reported crashes in various scenarios. In some areas, more than 50% of the bugs addressed were reported by customers through the MSDN Product...
Once again, Nikhil has out done himself. Check out his WPF/E Flickr Photo Viewer. You will need to download WPF/E December CTP to view it... WOW!
Not sure how many of you guys have experienced FxCop Rule# CA1002 : Do Not Expose Generic Lists through out your coding ventures. I'm not sure what to think of it... In one hand, I see the flexiblity of returning the IList<T> type since there could be x-number of things that could implemented. Thus not tying me up with a specific implementation such as List<T> or Collection<T>. On the other, Collection<T> does allow you to override functionality and also implements IList<T>. The rule does mention that List<T> (IList<T>) is designed for performance and Collection<T> is designed for inheritance... What are your thoughts on...
If you have the time, check out these great downloads add-ons for VS2005. I already have .NET 3.0 framework installed on my laptop and ready to play with WF and WCF...this is just sweet!
Essential Windows Workflow Foundation This is book is a really, really, really good read. The authors (both architects of WF) do a really great job of breaking down the concepts of what "makes up" a program...a basic approach they took into consideration when designing WF. If you're planning on using .NET 3.0, this is a worthy investment.
While trying to get our ci build to work, we ran into problems with the Oracle .NET Provider and NUnit. For some reason, there seems to be a threading issue with the provider and the way TestDriven .NET and UnitRun execute unit tests. In particular, the OracleConnection object, when you specify the string to be null or empty, an InvalidOperationException should be thrown. However, this is not the case...the exception is never thrown! If you run the unit test by it self, then the exception is thrown as expected. Weird. Have any of you run into this issue with the Oracle...
That's right, if you're planning on doing some development with the .NET Framework 3.0, you don't have to use CTPs, any more! They've shipped the product! This is the beginning of a brand new approach of application development for the Windows platform. Great job, teams!
Thanks to those of you that attended the meeting this evening! We had 29 people that made for a pretty good crowd. Please note that we WILL take into consideration the moving of the meeting place to West Des Moines. Like I mentioned several times, we just need a home that is not willing to charge us for the room. To get the slides and demos for the meeting, go here. Some one after the meeting asked, Why would I store my pages in the database? Well, all I can say is that it depends. If you need to interact with...
First and foremost, thanks to all of you that attended my presentation! We had a great crowd that was eagered to learn more about the inner workings of ASP.NET. Second, I would like to apologize for my buggy demo. Like I mentioned during the error, I moved the database file containing the content from my desktop to a folder under the C-drive so my connection string got hosed. I didn't take the time to check the demo to its entirety before showing it. My apologies. If you would like to get the demo code for the presentation, you can do...
Oracle Develop is the "developer"part for the OpenWorld conference. Remember, when I blogged about it couple of days ago? Yeah, I was pretty much in the same room for hours listening on how I can use their .NET tools to make things easier for developers. Verdict? Un-impressed. Why? Well, most of their content was the same content you can find on their website. The only things that made it ok was that I was able to talk with the developers of the product and discuss some of the issues/enhances with the product. I was also pleased to find out that they're planning...
I'm sure that I'm going to get a lot of crap from this, but here it goes... <RANT> While talking with a potential candidate today about what .NET language we were using on building our business layer & common library with, I mentioned that we will use C# for the common library and VB.NET for the business layer. He asked, "Why? You're current staff is mostly VB developers, wouldn't you just use VB.NET for all?". That's when I re-iterated that we're planning on using VB.NET for some of our business layer development. Since there's a small team (2 people) right now that...
Mike Stall has a really sweet post in he discusses some differences between conventional calls using the Object type and generics to casting for you within factory methods (Type CreateType() ). Worth the read if you're using generics beyond the traditional collection samples.
Finally got around to create a CodePlex project for LightBox.NET! (Yes, this LightBox.NET) No more file system versioning for me! (I know I could've used Subversion for my repository, but since I'm the only working on it, it was a bit of an overkill.) This is where I plan on storing all documentation, source code and requests for LightBox.NET, so if you're interested on the project, add this link to your favorites! A while back, I posted the release of version 0.1.2006.0726 on my blog, so to make things more formal I created a release candidate (RC) for ver0.1.2006.0726. Hope...
Roy Osherove has a great comparison of the popular unit test frameworks for .NET (MbUnit, NUnit and Team System Unit). I have to agree that for general testing purposes the standard is NUnit. Once you've grasped NUnit, MbUnit is a logical transition.
Well, looks like Nick beat me to the post! If you're doing Unit Testing or TDD, this is a great installment of Hanselminutes you should not miss! Scott has always done a great job with putting just the right amount of content to keep the listener interested and productive. This is not just me saying it, but Chris Sells too!
If you want to learn more about unit testing and being test driven, you should also check out this other Hanselminute.
Today I started to setup Continuous Integration (CI) with Team Foundation Server (TFS). Unfortunately, TFS does not support it out of the box; however, it does support functionality for you to hook-up into event sinks for comment server operations (Checkin, WorkItem assignment, etc). So, I Googled for "continuous integration team foundation" and ran into two really good posts by Jeff Atwood [post] and Daniel Cazzulino [post]. I particurlaly like solution that Jeff's post gives you, because he has added the page that kzu (Daniel) created and incorporated into his CI webservice. I wanted to take the solution even further by adding the automatic addition...
I ran into Buck Hodge's post on TFS tools on CodePlex and I must say that I'm pretty impressed with the selection of free tools out there.
In particular, I like the Code Review Workflow and Automaton offer. I played with Automaton today and for what is "there" it's not too bad. There is still some room for improvement but it gives implementers a pretty nice start to allow developers to kick start a build. As for Code Review Workflow, that's on the books for another day.
Another two projects to look at and consider are Source Code Tree Browser (this is...
A while back I posted about LightBox.NET and it's source code. From the looks of it, it was well received since people have blogged about it here and here. Also, someone has added it to their Magnolia bookmark list. To all out there, thanks! I know it's been three months since the initial release but as I've mentioned in other posts, I've been quite busy. I've spoken with several people about some of things I can do to make it “better” (along with the “can you make it run for ASP.NET 1.1?” .. trust me, if I had the time, I would do it...it's not that hard). So, here's my first attempt...
You learn something new everyday…
I was working on a simple demo application and had a method with a void signature:
static void Test() { … }
Messing around with the code, I decided to return System.Void at the end of my method instead of leaving the method without a return type or the return statement. To my surprise, these are the errors that I received from the compiler:
System.Void cannot be used from C# -- use typeof(void) to get the void type object.
Pretty interesting, huh? I should have guessed that there was an issue with this type in the IDE when I didn’t...
That’s right, looks like MS is renaming WinFX to be .NET Framework 3.0 to avoid confusion. Here’s what Soma had to say:
With this in mind we have decided to rename WinFX to the .NET Framework 3.0. .NET Framework 3.0 aptly identifies the technology for exactly what it is – the next version of our developer framework.
I guess I can see their point. At the end of the day, it’s just a name for packaging. Since we’re in the topic of changing names, can we rename WCF back to Indigo? ;-)
I would like to thank the CRIneta Admin group for allowing me to come and speak to their fine group. Nick tagged along for a night filled with pizza, demos and prizes. Thanks for the great time, guys!
During the meeting, Greg asked for information on performance between .NET Remoting and Enterprise Services, I told him of an article on MSDN that covered that topic (actually, I found two):
.NET Enterprise Services Performance
Performance of Web Services, Enterprise Services, and .NET Remoting.
I will be presenting an overview of .NET Enterprise Services at the Cedar Rapids .NET User Group (CRINETA) this coming Monday, June 5th. If live around the Cedar Rapids area, stop by and check out the show.
Due to time constraints, I will have to cut short (if not all out) some of the demos I did for the IADNUG meeting this past month.
That's right, Beta2 of WinFX (components, runtime and VS Add-ons) is out! Go download it and have fun playing with the new bits.
Microsoft Pre-Release Software WinFX Runtime Components - Beta2
Microsoft Windows Vista Beta2 Software Development Kit
Microsoft Visual Studio Code Name “Orcas” Community Technology Preview – Development Tools for WinFX®
I'm not sure about you, but this is pretty freakin' sweet. Nikhil is just amazing.
Even shorter...
namespace FrameworkPath{ using System; using System.Runtime.InteropServices; class Program { static void Main(string[] args) { Console.WriteLine(".NET Framework Path: {0}", RuntimeEnvironment.GetRuntimeDirectory()); Console.Write("Press <ENTER> to exit."); Console.ReadLine(); } }}
Stupid me...RTFM.
I needed to figure out how the directory path to the .NET Framework so I could lauch a process (regasm.exe) from an assembly. You would think that the System.Environment class or the Environment.SpecialFolder enumeration. Keith Brown posted how you can find it using P/Invoke with mscoree.dll. Well, instead of making a P/Invoke call, I wanted an easier way to looking for it. Here's what I came up with:
namespace FrameworkPath{ using System; class Program { static void Main(string[] args) { Type objType = typeof(object); string moduleName = objType.Module.FullyQualifiedName; string frameworkPath = System.IO.Path.GetDirectoryName(moduleName); Console.WriteLine(".NET Framework Path: {0}", frameworkPath); Console.Write("Press to exit."); Console.ReadLine(); } }}
Pretty straight forward.
FYI. I've created a CodePlex project or LightBox.NET. To find the latest source, please go check it out there!
Someone asked if I would post the source code for LightBox.NET. Well, here it is. Enjoy! If you have any ideas for extending it, please let me know!
A while back, I posted that I was working on another side project. One the cool things features of this website project is the use of the Lightbox JS script used to overlay images on the current page. I told Nick about me adding this to the site to make the pictures “cooler.” One of the first things Nick mention was that I had turned off the key-press events for navigating the pictures through a slide show. I was first confused by his comment since I've done nothing to change the Lightbox script. Well, it turned out that he thought I...
Should it blogged about it last night! ScottGu has a great post on the new CSS Control Adapter Toolkit for ASP.NET 2.0. This control adapter gives CSS-friendly capabilities to pre-excisting ASP.NET controls (Menu, TreeView, DetailsView, FormView and DataList).
Pretty nice way to hook into the new Control Adapter Architecture for ASP.NET 2.0.
Check it out if you got the time.
Decided to pick up this book by Joe Duffy.
I'm a follower of Joe's blog and love the information he shares on the inner workings of the CLR. I think the thing that "sealed the deal" was the table of IL instructions as an appendix in the back of the book.
&nbps;
Yes, I'm a sick individual. ;-)
In the latest issue of MSDN Magazine, there is an article that deals with the exposure of .NET functionality to existing VB6 applications.
The articles covers the use of the new COM Class item template that comes with VS2005 to expose functionality found in the new VB.NET My namespace language feature. The interop wrapper concept is a great way to allow your applications (both legacy COM and .NET) interact with one another with ease.
Currently, at a client site, we're using the same wrapper concept to expose services (classes that inherit from System.EnterpriseServices.ServicedComponent) to VB6 clients. Although, a VB6 client...
Doug Purdy posted some great information for using Remoting semantics (passing references and perserving object graphs) in Indigo. Here are the main links:
Perserving Object Graphs (Sowmy)
Passing References (Michael)
Eric Gunnerson posted earlier this week a simple C# Trivia quiz. This quiz contained questions such as "How many loop constructs does C# have?" and "What was the name of .NET before it became .NET?". Well, today he posted the answers to these questions. Pretty interesting trivia information. If you have the time, check it out.
Earlier today I was notified that I've been selected for the Microsoft MVP Award in ASP.NET for 2006. All I can say is that I'm deeply honored in being selected as a member of this fine community. I can't wait to collaborate with the rest of my fellow MVPs and continue to help out the community both online and offline.
My MVP Lead, Ben Miller, keeps a blog here, if you want to check it out. I can't wait to help him to make the ASP.NET community better!
Once again, thank you all for this great honor.
Just found this post from Charles Petzold that talks about a new language in the works called, C# Application Markup Language (CSAML). Petzold has great information on this new language and states that he will have a book released sometime next year.
The language looks pretty interesting. What do you think?
Ok, some of you might now this but this one is just for the record:
// Do this if you"re assembly// is located in your private bin path// and you wish to get your type dynamicallystring asmName = "PrivateAssembly";string typeName = "PrivateAssembly.MyType";object obj = Activator.CreateInstance(asmName, typeName).Unwrap();
// Do this if your assembly is in your// private bin path or in the GAC and// you wish to get your type dynamically.string name = "GlobalAssembly";string typeName = "GlobalAssembly.GlobalType";System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(name);System.Reflection.Assembly asm = System.Reflection.Assembly.Load(asmName);object obj = asm.CreateInstance(typeName);
This code makes all the difference when loading assemblies dynamically.
Ok, that was a stupid title. But hey, I’m not a comedian.
Just finished looking through the Stored Procedure Object Interface Layer (SPOIL) write up on MSDN’s Solution Architecture Center. SPOIL allows you to declaratively link a method with the same signature as the stored procedure (except using BCL types) together. For example, take this stored procedure sample:
CREATE PROCEDURE [dbo].[SendLog_Update] (@BatchId uniqueidentifier,@PartnerId nvarchar(50),@Mailbox nvarchar(50),@RootName nvarchar(100),@Directory nvarchar(100),@StartPackaging datetime,@TotalBytes bigint, @SendBytes bigint) …
To something like this in code:
[SqlCommandMethod(CommandType.StoredProcedure, "SendLog_Update")]public int SendLog_Update( Guid BatchId, [SqlParameter(50)] string PartnerId, [SqlParameter(50)] string Mailbox, [SqlParameter(100)] string RootName, [SqlParameter(100)] string Directory, DateTime StartPackaging, long TotalBytes, long SendBytes){ ... }
Kinda different, huh? Check it out and let me know what you guys think!
The new version of the .NET Pet Shop shows you how to migrate a v1.1 application to v2.0 of ASP.NET. Cool conversion features are the use of System.Transactions instead of Serviced Components, strongly typed collections to generic collections and extending the new membership modules.
You can dowload an MSI to install the source and the related databases. Pretty good stuff!
This is freakin’ sweet! Being used to work at a client’s site with VSTS and having Code Coverage tied with our unit tests, I’ve gotten a little spoiled. Well, the latest version of TestDriven.NET uses NCover and NCoverExplorer to provide similar function through it’s “Test with…Coverage” option. AWESOME!!
If you’re used to working with TestDriven and NCover as separate apps…STOP! Go get the latest version of the mentioned apps and enjoy the goodness!
A friend of mine from ISU, Kevin Moore, is now a PM for Avalon (WPF). He’s been recently featured on a MSDN TV episode where he and Robert Ingebretsen talk about templates in Windows Presentation Foundation.
Checkt it out! It's good stuff!
Have you guys noticed that ther'es no MSBuild task for installing assemblies into the GAC? Well, a while back, I wrote a task class to use for adding assemblies into the GAC.
You can check out what I did by downloading the project file. Hope this help you guys out!
For those of you creating applications in .NET 2.0, I hope that you’re taking advantage of generics. In particular, as the title of this post suggests, I hope you’re using constraints within your methods. Why? Well, with contraints in your methods you can do things such as this,
namespace GenericMethodConstraints{ using System; using System.Collections.Generic; class Program { static void Main(string[] args) { // Create the list of items based on the parameters List<Test> items = Driver.CreateList<Test>(10); // Loop through them and output their values foreach (Test t in items) { Console.WriteLine("{0} - {1}", t.ID.ToString(), t.Name); } Console.Write("Press <ENTER> to exit."); Console.ReadLine(); } } class Driver { public static List<TInterface> CreateList<TInterface>(int itemCount) where TInterface : ITest, new() { // Create a list of items List<TInterface> items = new List<TInterface>(itemCount); for (int i = 0; i < itemCount; i++) { // Check this out! I'm treating the interface as an object // because it has the new() constraint. TInterface iface = new TInterface(); // Set the properties for the instance iface.ID = i; iface.Name = i.ToString(); items.Add(iface); } return items; } } /// <summary> /// Interface needed for the constraint /// </summary> interface ITest { int ID { get; set; } string Name { get; set;} } /// <summary> /// Class that implements the interface for the constraint /// </summary> class Test : ITest { private int id; private string name; public Test() { } public int ID { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } }}
As you can see, you can set contraints on your methods that specify that your generic type is of a specific interface and that the class defines a constructor. This will allow you to create a type that implements your interface within that method. And you’re guaranteed that it will work since the constraints will be enforced at compile...
That’s right, the title is not wrong. You can download VS Express Editions free for one year at MSDN. Dan Fernandez posts more info about this great deal!
Go download Happy! Long live VS2005!
That’s right! I know it’s been a while since my last Code Project article! For this one, I decided to write about custom build providers in ASP.NET 2.0. Custom build providers allows you to extend your application by providing a class that generates source code for a custom resource (ie custom formatted file). If you get a change, go check it out!
Just got done watching this MSDN TV cast with Joel Pobar and Joe Duffy about how the CLR performs method dispatching for your objects. If you’re interesting on how your code works in the background, this is a must see!
A while back, Nick posted how you can use the Spring .NET Framework to have Design by Contract with AOP. I’ve been talking to him about you can do the same thing using a .NET remoting proxy to your object and intercept the calls to your objects. To do this, I needed three classes: An attribute to initialize the attaching at class level for wiring the AOP guts, a class that wires up the AOP guts and a sink that performs the interception. This is a modified version of Nick’s code:
using System;using System.Reflection;using System.Runtime.Remoting.Activation;using System.Runtime.Remoting.Contexts;using System.Runtime.Remoting.Messaging;namespace Lozanotek{ public interface IEvaluator { bool Evaluate(object arg); } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class PrologAttribute : Attribute { private int index; public IEvaluator evaluator; public PrologAttribute() { } public PrologAttribute(int index, Type evalType, params object[] args) { this.Index = index; Object obj = Activator.CreateInstance(evalType, args); if (obj != null) this.evaluator = obj as IEvaluator; } public IEvaluator Evaluator { get { return evaluator; } set { evaluator = value; } } public int Index { get { return index; } set { index = value; } } public bool Evaluate(object arg) { return evaluator.Evaluate(arg); } } public class StringLengthEvaluator : IEvaluator { private int min = 0; private int max = 0; public StringLengthEvaluator(int min, int max) { this.min = min; this.max = max; } public bool Evaluate(object arg) { int len = arg.ToString().Length; return (len <= max) && (len >= min); } } [AttributeUsage(AttributeTargets.Class)] public class AOPClassAttribute : Attribute, IContextAttribute { public void GetPropertiesForNewContext(IConstructionCallMessage msg) { msg.ContextProperties.Add(new AOPProperty()); } public bool IsContextOK(Context ctx, IConstructionCallMessage msg) { return false; } } internal class AOPProperty : IContextProperty, IContributeServerContextSink { public AOPProperty() { } public void Freeze(Context newContext) { } public bool IsNewContextOK(Context newCtx) { return true; } public string Name { get { return "AOPProperty"; } } public IMessageSink GetServerContextSink(IMessageSink nextSink) { return new AOPMessageSink(nextSink); } } internal class AOPMessageSink : IMessageSink { private IMessageSink next; public AOPMessageSink(IMessageSink next) { this.next = next; } public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink) { return null; } public IMessageSink NextSink { get { return next; } } public IMessage SyncProcessMessage(IMessage msg) { bool proceed = true; if (msg is IMethodMessage) { proceed = Invoke(msg as IMethodMessage); } return (proceed) ? NextSink.SyncProcessMessage(msg) : new ReturnMessage(null, null, 0, null, (IMethodCallMessage) msg); } private bool Invoke(IMethodMessage msg) { bool results = true; MethodBase method = msg.MethodBase; Type attrType = typeof(PrologAttribute); PrologAttribute[] prologs = method.GetCustomAttributes(attrType, true) as PrologAttribute[]; if (prologs != null) { foreach (PrologAttribute pl in prologs) { if (pl != null) { IEvaluator eval = pl.Evaluator as IEvaluator; if (eval != null) { object[] args = msg.Args; results = eval.Evaluate(args[pl.Index]); if (!results) { break; } } } } } return results; } } [AOPClass] public class Person : ContextBoundObject { [Prolog(0, typeof(StringLengthEvaluator), 0, 5)] public void SayHello(string name) { Console.WriteLine("Hello {0}", name); } } class Program { [STAThread] static void Main(string[] args) { Person p = new Person(); p.SayHello("Javier"); p.SayHello("Jav"); Console.ReadLine(); } }}
If you have any questions or comments, let me...
During my Indigo talk at the HDC, I was asked about load balancing to another endpoint if your current proxy endpoint is down. I took a look at this problem during lunch today, and this is what I did to solve it:
If you created your proxy using svcutil, you will have a local copy of the service interface. In my second demo, I had the IEightBallService interface under my EightBallProxy.cs file. The main proxy class, EightBallServiceProxy, inherits from System.ServiceModel.ClientBase<T> and implements the generated IEightBallService interface.
The EightBallServiceProxy class also encapsulates a System.ServiceModel.ChannelFactory<T>. Which in turn, exposes a ServiceEndpoint through the ChannelFactory<T>.Description.Endpoint property. So,...
A couple of days ago, Don Box posted about WFPad. In his post he mentioned that he wanted IndiPad. Well, after working on for two hours last night, this is my take on IndiPad:
This version of IndiPad has limited functionality!! To open a .config file, you will need to select it’s corresponding assembly. In other words, if you want to open myclient.exe.config, you need to select myclient.exe in the dialog. Why? Well, I’m using the ConfigurationManager.OpenExeConfiguration method to load the .config file into a Configuration object. This way, I can get the system.serviceModel/services and system.serviceModel/client config sections (Ok, I cheated and disected...
Today at work, Seth, one of my friends, was explaining me the default behavior of VB.NET as a response to my previous post. Apperantly, VB.NET boxes native types automitically for you. So when you set an Integer to Nothing, it’s all good. In other words the following code is all good in VB.NET,
Dim i As Integer = 10Dim o As Object = io = Nothingi = CInt(o)
As expected, this C# code throws a NullPointerException in the unboxing from object to integer,
int i = 10;object o = i;o = null;i = (int) o;
All I have to say is that VB.NET is messed up.
While working with generics, I’ve realized this about their behavior with default values for types in C# and VB.NET. For example, if you have the following simple generic method in C#:
public static T GetDefault<T>(){ return null;}
For those C# inclined, you will notice that this function will not compile. Why? Since the method is generic (and without constraints), the compiler cannot assure the value of null for the type. In other words, the call
int i = GetValue<int>();
obviously breaks this assumption. Fortunately, the language offers the default construct that will return, well, the default value for a generic type. In other words, for int it will return 0 and for...
Lately, I’ve been working a lot in .NET 2.0; specially with generic collections. After working with System.Collections.Generics.List, I’ve learned to appreciate its ForEach method. Oh, how much it reminds me of the map procedure in Scheme. Can you tell which code is faster?
namespace GenericList{ using System; using System.Collections.Generic; using System.Diagnostics; class Program { static void Main(string[] args) { string[] numbers = { "1", "2", "3", "4", "5"}; List<string> numberList = new List<string>(numbers); // Create a watch to time the execution! Stopwatch watch = new Stopwatch(); watch.Start(); // Old boring way! foreach (string string1 in numberList) { Console.WriteLine("First For-Loop Value: {0}", string1); foreach(string string2 in numberList) { int n1 = Int32.Parse(string1); int n2 = Int32.Parse(string2); Console.WriteLine("\tSecond For-Loop Value: {0}+{1}={2}", n1.ToString(), n2.ToString(), (n1 + n2).ToString()); } } watch.Stop(); Console.WriteLine("For-loop time: {0} millisec(s)", watch.ElapsedMilliseconds.ToString()); // One empty line for ease of read Console.WriteLine(); watch.Reset(); // Get value of list without loop! watch.Start(); numberList.ForEach(new Action<string>( delegate(string s) { Console.WriteLine("First Delegate Value: {0}", s); // Lets loop again! numberList.ForEach( new Action<string>( delegate(string s2) { // Convert to numbers int num1 = Int32.Parse(s); int num2 = Int32.Parse(s2); // Output the simple loop sum Console.WriteLine("\tSecond Delegate Value: {0}+{1}={2}", num1.ToString(), num2.ToString(), (num1 + num2).ToString()); } ) ); } ) ); watch.Stop(); Console.WriteLine("Delegate time: {0} millisec(s)", watch.ElapsedMilliseconds.ToString()); watch.Reset(); Console.ReadLine(); } }}
[OverDuePost]
While working with COM interop (VB6 client / .NET Server), our architecture team ran into some problems with returning typed arrays back to the client. I had spent over two hours trying to get things working with the correct set of attributes, but I kept on getting “Type Mismatch” errors in VB6. I had to leave early to meet up with my wife and Fred and Nick stayed after to help with more research. This is our brain child:
Domain object (and interface) that is used by VB6 to populate its UI
namespace InteropLibrary{ using System; using System.Runtime.InteropServices; [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("905816E8-9C73-42f0-A776-7117ACF633BD")] public interface IPerson { [DispId(1)] string FirstName { get; set; } [DispId(2)] string LastName { get; set; } [DispId(3)] string ID { get; set; } }}
namespace InteropLibrary{ using System; using System.Runtime.InteropServices; [ClassInterface(ClassInterfaceType.None), ComDefaultInterface(typeof(IPerson)), ProgId("Interop.Person"), Guid("135983AB-8242-41fb-8ED8-FDE3383A2FDD"), Serializable] public class Person : IPerson { string firstName; string lastName; string id; public Person () { ID = Guid.NewGuid().ToString(); } public string FirstName { get { return firstName; } set { firstName = value; } } public string LastName { get { return lastName; } set { lastName = value; } } public string ID { get { return id; } set { id = value; } } }}
Server object (and interface) used by VB6 to return either a single...
A LINQ (Language INtegrated Query) paper by Don Box and Anders Hejlsberg has been posted on MSDN. I haven’t read all of it yet, but so far so good.
The paper gives you a great deal of information of the functionality and features of the new framework.
ScottGu has posted the code for the Atlas keynote. Check it out, it’s pretty damn cool!
Kent Tegels chimes in about his impressions of LINQ. Kent has a great set of points (and concerns) with the new framework. I specially agree with his fourth point.
Thanks Kent for your input!
Interesting observation:
Has anyone else noticed that some of the features defined by the C-omega language (download) are being split between the 2.0 and 3.0 version of the language? Don’t get me wrong, I think it’s awesome that the language is getting all of these awesome features. I just find it a bit interesting that they waited this long to release all of the goodness…
Here’s an excerpt from the article link above:
C? includes a number of constructs from the SQL language as keywords. Operators for performing selection with projection, filtering, ordering, grouping, and joins are all built into C?
If you look at the LINQ...
This is awesome! Read about C# 3.0 and Visual Basic 9.0 and their sweet features.
C# 3.0 is going to be sweet…
Ok, well first and foremost, I would like to apologize for my delay of this post. Lately work has been sucking my brain dry!! When I get home, I just want to stare at a wall and pretend the pain is gone. Don’t get me wrong, I love what I’m doing right now, but I get so deep into it that it even haunts my dreams!!
What is this haunting? Well, it’s Enterprise Services. I’ll get to the reason in just a bit. The code I posted a while back asked a simple question, what does the code output?………Bueller? Bueller? Bueller?...any one?...
What does this code output?
.csharpcode
{
font-size: small;
color: black;
font-family: Courier New , Courier, Monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
1: namespace GenericsExample 2: { 3: using System; ...
Follow the yellow bricked road...
1 using System;
2
3 [assembly: Attributes.Instance(TypeName = "Classes.Something")]
4 [assembly: Attributes.Factory(TypeName = "Classes.SomethingFactory")]
5
6 namespace Attributes
7 {
8 [AttributeUsage(AttributeTargets.Assembly)]
9 class InstanceAttribute : Attribute
10 {
11 private string typeName;
12
13 public string TypeName
14 {
15 get { return typeName; }
16 set { this.typeName = value; }
17 }
18 }
19
20 [AttributeUsage(AttributeTargets.Assembly)]
21 class FactoryAttribute : Attribute
22 {
23 private string typeName;
24
25 public string TypeName
26 {
27 get { return typeName; }
28 set { this.typeName = value; }
29 }
30 }
31 }
32
33 namespace Interfaces
34 {
35 interface ISomething
36 {
37 void Do();
38 }
39
40 interface ISomethingFactory
41 {
42 ISomething GetSomething(Type t);
43 ISomething GetSomething(string typeName);
44 ...
Brad Abrams, .NET Framework PM, posted this interesting tidbit about using the Length property of an array directly in a loop as supposed to assigning it to a local variable. For example: int length = myArray.Length;
for (int i=0; i<length; i++)
for(int i=0; i<myArray.Length; i++)
If you have time, I suggest you read it. You'll be surprised on how the framework handles this issue.
I finally wrote my first Code Project article! The article is called Extending ASP.NET Web Controls With Custom HTML Attributes, if you have the time check it out and tell me what you think! Also, I will like to extend my deepest thanks to Nick for pushing to write an article.
A recent Computerworld survey has placed C# as the top of the Top 5 programming languages reported in use by respondents list.
Here's a list of the results for languages:
C# - 72%
Java - 66%
Visual Basic - 62%
C++ - 54%
JavaScript/ECMAScript - 50%
If you have the time, I suggest you read it. It's worth the time!
Good question! Anonymous classes in Java allow you to implement adapter classes within your code. Huh? Pretty simple, if you have a class that returns an Enumeration interface (like a custom list, stack, etc.), you can define the implementation of the code right on the method declaration. To get a better grasp of it, check this example from the Java tutorial, also please note the last sentence regarding their usage in code.
Ok, how does this tie to .NET? Well, for some time I've been talking with Nick about this feature of the Java language and how sweet it will be...
... to the C# developer that's coding it. Nick and I have been quite busy working on a VB.NET web project for Sprint. As some of you know, Nick and I are pretty fleunt in C# (the fact that Nick is an MVP for the language proves that at least he is!), so our VB.NET code doesn't flow as smoothly as our C#-syntax does. It took Nick 5 minutes to write a simple handler (.ashx) in C# and an additional 20 minutes to make it work in VB.NET...that's just a poor use of a resource's abilities! It's like me asking...
While look through microsoft.com's webcast events, I ran into their Modern Software Development Using C# series. It's a series of 15 webcasts that will cover a range of topics dealing with Windows development. So if you are just starting on .NET or are interested on the subject feel free to check them out.
This is the compliment to the previously released VB.NET sessions.
This material from Don Box is a little dated, but it covers our soon-to-be-friend [ServiceContract] pretty well. Also, Nick and I were scetching some ideas on the board of how to come up with a pseudo-Indigo for dnfx 1.1...our ideas are some what rough, but I think there's something brewing.
I just finished reading, Dave Chappell's article on Indigo. Man, I can't wait until we have access to the CTP! If I were to pull three main points from the article, I will say the following:
Indigo surely emcompases all 'distributed' computing technologies under an easy to use bundle (see Nick's post).
Indigo pushes developers to think of services as components of their applications rather than something mystical and external to their application.
Indigo makes you wonder if your current (serviced|distributed)-architecture can withstand a smooth migration.
The most interesting section of the article was titled Coexistence and Migration. Dave outlines how...
Currently, I'm doing a lot of work in VB.NET...yeah, I know...so if you take a look at my VB code, it has a a bit of a C-hint to it. I guess, I just miss some of the nice language constructs C# has to offer. In particular, the terniary operator (? operator). After making writing several pseudo-terniary statements in VB, I decided to look at the IL that makes up the C# and VB.NET statements. So, let's take a look at the C# statement first:
namespace Lozanotek.Examples
{
using System;
public class TerniaryTest
{
public TerniaryTest()...
The System.Security.Principal.WindowsPrincipal class was intended, according to MSDN, to allow code to check the Windows group membership of a Windows user. For example, ADO.NET uses this class to access a SQL Server resource when the connection string specifies the usage of Integrated Security by accessing it via the Thread.CurrentThread.CurrentPrincipal property.
Of course, if you are going to have a WindowsPrincipal, you need a System.Security.Principal.WindowsIdentity, a representation of a Windows user, class to interact with it. Unfortunately, you cannot create an identity from a constructor or managed method. Instead, you are restricted to use the Win32 API function LogonUser that's under...
Ok, so you've written your share .NET assemblies (by this I mean both .dlls and .exes) in C# or VB.NET ... or even better, COBOL! But have you ever wondered how it all happens? It is just smoke and mirrors? If any of you have read (or are currently reading) Jeffrey Ritcher's book, Applied .NET Framework Programming, you can recall that in pages 9-18 he gives you a pretty good run down of how the CLR is loaded when you execute a simple program, for example the infamous Hello World.
But this post is not about Richter's book example (although,...
Brad Abrams has posted a list of the coding standards for C# used by Microsoft. I will have to say, "WOW!" After looking at this, I realize that I'm huge violation of the correct way of formatting my code. (Granted my C# standards are great mixture of my C++/Java standards).
If you have time during lunch today, I say it's worth taking a look...and start changing those 'bad' coding-habits.
Long ago, while browsing the great pages of MSR (if you don't do that know, I suggest you do from time to time), I stumbled into a C# language-extension called, Polyphonic C# (Poly-C#), an extension that offers asynchronous concurrency abstractions for distributed programming (whether it be multi-threaded or multi-machine).
A while back, my good friend Nick had a quick post about the new .NET research language C-Omega, a C# superset. This peaked my interest a little. I asked myself, “Adding more cool stuff on top of C#?! Is there no end to the greatness?” I started digging into this new phenomenon...
To my surprise, the people...
While browsing through MSDN, I bumped into the Microsoft ASP.NET Webcast Series. It's nothing more than a collection of more than 40 hours of free, on-demand ASP.NET-goodness!
If you have some free time, I suggest you take a look.
I was playing around with some code today and I wanted to explore a good mixture of polymorphism and inheritance on my example. So, I decided to come up with an example that used interfaces and interface-inheritance. Take a look at the following code:
// Simple interface defining one method
public interface ISampleA
{
// Leave the definition to the implementor
void DoTaskA();
}
// Another simple interface defining one method
public interface ISampleB
{
// Leave the definition to the implementor
void DoTaskB();
}
// Make things fun...This interface inherits from the other two
...
Lately, I've been posting some code samples on how to do simple threading using Delegates as well as handling event registration manually. Nick pointed out the following post by Brad Adams that talks about a possible race condition when invoking an event (a)synchronously. Take for example, the following code:class ClassA
{
public event EventHandler SomeEvent; protected virtual void OnSomeEvent(object sender,EventArgs e)
{
if(SomeEvent != null)
...
I was looking through the C# Language Specification and bumped into the following explanations about Events section 1.7.5:
For a simple event declaration such as
public event EventHandler Click;
the compiler automatically provides the implementation underlying the += and -= operators.
An implementer who wants more control can get it by explicitly providing add and remove accessors. For example, the Button class could be rewritten as follows:
public class Button { private EventHandler handler;
public event EventHandler Click {
add { handler += value; }
remove { handler -= value; } }}
This change has no effect on client code, but allows the Button class...
Currently at work, I'm working on a VB.NET web application. Since, I'm C-inclined (C++, C#,Java) it's kinda hard switching back to writing in BASIC. So, I've been using this handy-dandy web page to help me translate back and forth. To my surprise, the author of this page also created the same thing for Java (1.5)/C#! This is also pretty handy in realizing how SIMILAR the languages are...however, C# is better cause it has structs! (just kidding)
Hope you find these links as useful as I have!
When I worked at Principal, we used Ant a lot for building our JARs and EARs against our code repository. Also, we used to aid the already tideous EAR deployment process. I've known of NAnt for quite some time, but never actually played with it...My reasoning was...why should I? I have VS.NET!
One of my 'New Year's Resolutions' was to get more in-touch with .NET (abstract concepts, languages, CLR) and .NET Related tools (aside VS.NET). Thus far, I have played with NUnit and as I suspect it, I picked up rather quickly thanks to my previous JUnit exposure. So tonite, before...
A while back, I had a post that showed how you could check if a file was a .NET assembly. Well, around that time, I wrote a simple application to test this function. However, the way I did the test app is not ... how should I put it ... common. I decided to use threading to facilitate the searching of the assemblies under the netfx folder...the threading has a little bit of a twist. It uses a custom delegate (a class that maps to System.Delegate ... well, it's more like System.MulticastDelegate, but I'll let you read about it!) to do the dirty work of searching!
If you...
My good friend Nick Parker was awarded the Visual C# MVP (Most Valuable Professional) award for 2005! This award is given to professionals that go above and beyond the call of duty in development communities by assisting their peers.
Please join me on congratulating Nick on this great accomplishment!
Yesterday, I posted an answer to a question on Code Project dealing with evaluating expressions in C#. The person who asked the question wanted to know how to evaluate expressions with an eval() function (like the one in JavaScript/JScript).
After playing around with some code snippets, I came up with the following answer:
using System;
using Microsoft.JScript; //Microsoft.JScript.dll
using Microsoft.JScript.Vsa; //Microsoft.Vsa.dll
string expr = @" var x = 11; var y = 'A'; var bEval = false if ((x > 10) && (y == 'A')) { bEval = true; } else { bEval = false; }";
VsaEngine engine = VsaEngine.CreateEngine();object o = null;try{ o = Eval.JScriptEvaluate(expr,engine);}catch(Exception e){ Console.WriteLine(e.Source); Console.WriteLine(e.StackTrace);}
Console.WriteLine(o); //Outputs 'True' to the consoleConsole.ReadLine();
Enjoy the code!
Today, my dear friend SharpReader brought me back an interesting post with an interesting correlation. Have a read and tell me what you think ...
While reading through my usual blog listings, I came across a posting by Jeffrey Richter's wintellect blog that talked about code performance via the JIT. After reading his posting, along with other related cases, I decided to try it out. So, I took his code and 'converted' back to .NET 1.1 and this is what I got:
1: using System;
2: using System.Diagnostics;
3:
4:
5: public class App
6: {
...
While reading through my archive of RSS feeds from other blogs, I bumped into this one from Suzanne Cook. After reading it, I thought...hmm, maybe I should write a function to do that for me ... so here it is, a C# version of an assembly verifier:private const int COR_E_ASSEMBLYEXPECTED = -2147024885;private bool IsAssembly(string asmFile)
{
bool isAsmbly = true;
try
{
AssemblyName.GetAssemblyName(asmFile);
}
catch(BadImageFormatException imageEx)
{
...
While reading an article by Dino Esposito from Wintellect, I bumped into this little beauty from Jeff Prosise, another Wintellect guru. This article covers pretty 'high level' ASP.NET coding to show you how you can protect your sessions from potential hackers. It's a must read for those interested in core ASP.NET development.