.NET (RSS)

.NET

WiX v2 Manual Online

Rob Mensching writes in a post that WiX has an online manual for version 2 and that eventually a manual for version 3 will show up.

The 0xe0434f4d code

Have you ever experienced the 0xe0434f4d exit code and thought, what the heck is that!

Tess has a nice blog If broken it is, fix it you should which in a post explains how to interpret the exit code which is very good.

0xe0434f4d means that it is an exception from the CLR, ie any managed exception is referred to with this code.

And she also explains what the funny 0xe0434f4d means:
0x43 0x4f 0x4d are the ASCII codes for COM!

Stored Procedure Object Interface Layer - SPOIL

Check this out - Stored Procedure Object Interface Layer (SPOIL).
It's a really nice framework to use when working with Stored Procedures. It helps you map stored procedures directly to methods in .NET applications.

Concerned about the Microsoft Windows Presentation Foundation and the new UI looks

I'm a bit concerned about all the new user interfaces and layouts that will appear when application developers starts taking use of the Windows® Presentation Foundation (formerly code named "Avalon"). This "tecnology" is awesome but it has it's drawbacks. With the WPF you can create applications that are really neat looking and have high usability, just take a look at Microsoft Expression Interactive Designer. I saw a really nice demo, on a Microsoft Partner event, of a medical journal application looking like a "medical journal" - not the old fashioned MDI interface with a File, Edit... menu. And I guess most of you have seen the Microsoft Max application and the new Office 2007 interface.

But what will happen to the usability between applications? As of today almost all Windows applications has a user interface with a menu bar with the File, Edit etc menus, a toolbar with icons and either one document (SDI) or multiple documents (MDI) in the window area. This is very good when adapting to new applications, you know where to find the functionality you want, not in all cases but the most vital functions are easily found. You know how to save a document or to paste something in to your application.

Windows Presentation Foundation does not prohibit this usage but it allows developers to create really cool looking applications with a nice user interface. But when it comes to recognizing functions and behaviours I think this will cause a lot of trouble.

Let's take an example of a hospital, where I have seen similar troubles, having several applications from several vendors; they have Microsoft Office 2007, some kind of medical journal system, a financial report system, an intranet etc. Most of the employees use more than one application. It will be very problematic if these applications doesn't share the same user interface guidelines. This is the point of my entry! Where is the guidelines for these new awesome user interfaces?

Do you have the same opinion or experience as I do?
Where can I find information on how to make these new applications run smoothly togheter using common guidelines?

Under the skin of Atlas

I'd like to share my thoughts and insicts on the Microsoft ASP.NET Atlas project. ASP.NET Atlas is a library of rich UI functionality using Ajax.

The thing that caught my interest at first was the way the JavaScript library was created. First of all it is not solely created for Internet Explorer, as most of Microsoft products have been before, but also for Firefox, Mozilla and Safari.

After going through all of the JavaScript code you can find some rellay interesting things that have made the JavaScript APIs really nice:

  • Namespaces - organizes the classes and methods into a nice hierarchy
  • Class inheritance - makes it possible to create abstract classes and inherit from other classes
  • Interfaces - makes it possible to define an interface from which a class can derive
  • Delegates
  • Callbacks

For example the class Web.UI.TextBox inherits from the Web.UI.InputControl class which is derived from the Web.UI.Control class and the Web.UI.IValidationTarget interface.

This is all achived using a few methods, two of the caught my immidate attention:

registerNamespace(namespacePath): Creates a namespace

Type.registerClass(typeName, baseType, interfaceType): Defines a class with a typeName which inherits from the baseType and optionally derives from an interface.

All defined classes that inherits from another class uses the initializeBase(instance, baseArguments) method, which is a kind of constructor. The initializeBase method is a prototype function on the Function function (Function.prototype.initializeBase =function(instance,baseArguments)).

Going through this opened a new way of programming with JavaScript, for me. Please do check it out, and make nice rich UI web applications.

Note: The Atlas API's are used on Start.com, Windows Live and others.

SPException: Save Conflict (0x81020037) in IListEventSink

When using the IListEventSink to create event handlers for Microsoft SharePoint 2003 you often make changes to one or more properties of lists. I have an event handler that automatically inserts a document id in Document Libraries. When a document is inserted an id is set on one of the fields, and to save it the Update method on the SPListItem object has to be executed, which will create another event (an Update) in which you may change other properties. More than once me and my colleagues has recieved the dreaded SPException: Save Conflict exception on the Update event.

Microsoft.SharePoint.SPException: Save Conflict
Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.
---> System.Runtime.InteropServices.COMException (0x81020037): Save Conflict

The exception is not easy to track down but is really easy to resolve. In our cases we use an SPWeb object to get the item and that class inherits the IDisposable (not mentioned in the documentation nor the examples, somebody expected that from the SharePoint documentation?). That means that one should take care of Disposing the object after usage. So using the using statement in C# on the SPWeb object saves us from the exception. For those of you that uses other programming languages, don't forget to call the IDisposable.Dispose() method.

Framework design guidelines discussion

Brad Adams has a good series of articles and discussion on the Framework Design Guidelines. I recommend you to take a peek at it before leaving the job this snowy (at least in Sweden) afternoon.

Documentation of your code

Visual Studio.NET C# introduced to the Microsoft developers* a nice inline Xml based documentation method, called Xml Documentation. For the development cycle the documentation is a big challenge to all developers, especially in large projects and/or long projects.
The code documentation should be a part of your coding guidelines, see previous posts.

The output of the Xml Documentation is an Xml document, which is used by the Visual Studio intellisense and others. To make it more available I recommend using NDoc. I have used this easy but powerfull program for a few years and it is great for making a nice documentation to share with your developers or clients.

Though the NDoc utility is good in compiling your Xml documentation to a nice delivery it does not help you to make the documentation, ie write the text!

But I recently found a nifty utility that makes this step so much easier: GhostDoc. With a simple keypress the GhostDoc Visual Studio add-in creates the stubs for documentation by checking the name of the method.
Example output from GhostDoc:
/// <summary>
/// Adds the filter.
/// </summary>
/// <param name="columnId">The column id.</param>
/// <param name="value">The value.</param>
public void AddFilter(string columnId, object value) {

It's that easy, go download it right now! A big up to Roland Weigelt for this application!

*There are several other good methods such as JavaDoc, PerlDoc etc.

Running ASP.NET 1.1 and 2.0 side by side

A really nice feature when using .NET Framework 2.0 (beta) is that you can run ASP.NET 1.1 nad ASP.NET 2.0 side by side on the same IIS. You can configure individual virtual directories in the IIS to use different version. The IIS Management Console has a new tab called ASP.NET, see image below, in which you can select which version you would like to use, whithout doing a lot of script-mappings.

This makes it really easy to make new applications take usage of the new .NET Framework while your old applications still use the .NET 1.1.


This blog has moved to http://www.wictorwilen.se/.

Application and Class Designer, part II

My last article commented on the lack of integration between the Application Designer and the Class Designer in the new Visual Studio 2005. I have gotten some feedback from the Class Designer Team at Microsoft about this. They "realize that [their] integration story between AD and CD is still not ideal" as a first version. I am really glad to here this. They also plan to address these issues in future releases of Visual Studio, I really hope we don't have to wait another 3-4 years until the next new version of Visual Studio and that Microsoft plans for this in some kind of Service Release or similar.

 

Evaluating the VS.NET 2005 Application Designer

I have done some evaluation of the Application Designer and Class Designer in the Visual Studio 2005 beta. I really like them both, especially the Class Designer. The Application Designer is of great use for making analysis of loose coupled systems prior development and deployment.

But I really think there is some missing parts of the Application Designer and there is a missing link between the Class Designer (or perhaps I missed something out!!). For example I work on a pretty large system, with several assemblys loaded into a web project. The system also contains webservices and databases. The web project, web services and databases fits nicely into the Appliction Designer. But there is no nice and easy way to divide, for example, the web project into smaller entities (read assemblies, Windows services etc), ie there is no direct link between the Application Designer and Class Designer. It would be nice to be able to drill-down from an Application System, to the Application Designer to the Class Designer.

What do you think, or do you have any nice ways to achive this?

The LINQ Project

Microsoft has a really interesting project, codename LINQ, that will extend the .NET Framework. It's a set of language extensions that will be introduced to C# and Visual Basic, in later versions (not veriosn 2). LINQ stands for Language Integrated Query and read more about it in the Microsoft pressrelease.

LINQ contains an SQL like query syntax, see below, as well as query language for querying relational data and Xml.
var numsPlusOne = from n in numbers select n + 1;

I really like this syntactic sugar idea and will enable developers to make the code more efficient.

For you guys visiting the PDC 05, Don Box is moderating a LINQ panel tomorrow. Check it out and keep us (that has to be home and continue working on projects) informed!

Excellent article on Credentials and Delegation in ASP.NET

The september 2005 MSDN Magazine presents an excellent article in the Security Briefs column about credentials, impersonation and delegation in ASP.NET, called Credentials and Delegation.

Keith Brown rellay explains all the various ways on how to get these things to work. I also recommend reading his books, and one of them you can find in Wiki form: The .NET Developer's Guide to Windows Security.

Updated ComPlusWrapper class

Here is an updated version of the ComPlusWrapper that I previously published, this one contains a Hashtable for caching the ProgId/Types as well as a method for invoking methods.
Please post any comments to the code or any improvments to the class.

public class ComPlusWrapper : IDisposable {
  private static volatile Hashtable s_types = new
Hashtable();
  private static volatile Object s_lock = new
Object();
  private object
_ComPlusObject; 
  private Type _type;
  private bool _IsDisposed = false;

  public ComPlusWrapper(string ProgId) { 
   
if(s_types.ContainsKey(ProgId)) {
     
_type = s_types[ProgId] as Type;
   
} else {
     
lock(s_lock) {
       
_type = Type.GetTypeFromProgID(ProgId, true); 
       
s_types.Add(ProgId, _type);
      }
    }
  _ComPlusObject = System.Activator.CreateInstance(_type);
  }

  ~ComPlusWrapper() {
    this.Dispose();
  }

  public object ComPlusObject{
   
get {
     
if(this._IsDisposed) {
       
throw new ObjectDisposedException(null);
     
}
     
return _ComPlusObject;
    } 
  }

  public Type ComPlusType {
   
get {
     
if(this._IsDisposed) {
       
throw new ObjectDisposedException(null);
     
}
     
return _type;
    
}
  }

  public void Dispose() { 
   
if(!this._IsDisposed) {
     
IDisposable dispose = _ComPlusObject as IDisposable; 
     
if(dispose != null) { 
       
dispose.Dispose(); 
     
} else {
       
System.Runtime.InteropServices.Marshal.ReleaseComObject(_ComPlusObject);
     
}
     
_type = null;
     
_ComPlusObject = null;
    } 
   
GC.SuppressFinalize(this);
    this._IsDisposed = true;
  
}

  public object InvokeMember(string Name, object[] Arguments) {
   
return _type.InvokeMember(Name, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.IgnoreCase, null, _ComPlusObject, Arguments); 
 
}
}

OneNote managed API

Donovan Lange has published a preview of the Microsoft OneNote managed API.

Can't wait to get some time to try it out!

Mono Beta 3 is out!

Not long after beta 2 the Mono, Novells open source free .NET implementation, project has released beta 3. Check it out on the http://www.go-mono.com/ site.

Need more OneNote information?

Then go check out Andrew May's great blog at http://blogs.msdn.com/andrew_may/
It's perfect for keeping up with the upcoming changes in the SP1.

System.Web.Mail problems?

Thanks to Dave Wanta all problems with System.Web.Mail has been solved!

Check out his Complete FAQ for the System.Web.Mail namespace at http://www.systemwebmail.com/.

Using Dotfuscator in the post-build process

When using Dotfuscator to obfuscate your code you may find this tip helpful, since it automates the process of obfuscating.

Under Project Properties/Common Properties/Build Events and Post-build Event Command Line you can enter the following to automate the obfuscation process:
"C:\Program Files\PreEmptive Solutions\Dotfuscator Community Edition 1.1\dotfuscator.exe" /q ..\..\Dotfuscator.xml
copy ..\*.dll *.dll
This assumes that you have created a Dotfuscator project (Dotfuscator.xml) in your project and that ILdasm in your path and that the output of Dotfuscator is the bin folder of the project (change the copy statement if you have another output directory).

Now after a successful build Dotfuscator will obfuscate your DLL.