DCSIMG
August 2007 - Posts - Guy Burstein's Blog

Guy Burstein's Blog

Developer Evangelist @ Microsoft

News

Guy Burstein The Bu

Disclaimer
Postings are provided 'As Is' with no warranties and confer no rights.

Guy Burstein LinkedIn Profile

TwitterCounter for @bursteg

August 2007 - Posts

ADO.Net Entity Framework Screencast - Introduction [HE]

ADO.Net Entity Framework Screencast - Introduction [HE]

I've posted earlier that . I've taken few moments to show what is possible when using it.

This screencast is in Hebrew, but you can fully understand it by watching only.

I've love to get your feedback on the screencast and about the technology, and if you have any questions about it, please comment!


View Video
Duration: 11:53

Download the screencast(WMV)

Enjoy!

ADO.Net Entity Framework Beta 2 is available

ADO.Net Entity Framework Beta 2 is available

Entity Framework Beta 2 The ADO.Net Entity Framework bits for Visual Studio 2008 Beta 2, and the CTP 1 of the Entity Framework Tools is available for download. Read the ADO.Net Team announcement .

The ADO.NET Entity Framework Tools Preview CTP contains a preview release of the ADO.NET Entity Designer which enables users to visually design model and mappings using Visual Studio 2008 Beta 2. The designer in this CTP has limited functionality and only supports a subset of the ADO.NET Entity Framework.

If you're interested in finding more about the ADO.Net Entity Framework, visit here.

Mike Tualty has already posted some helpful information about the new release features that can be found here:

Enjoy!

Software Factories Support for Visual Studio 2008

Software Factories Support for Visual Studio 2008

Software Factories Visual Studio 2008 Since the release of Visual Studio 2008 Beta 2, and the release of GAT/GAX July CTP that supports it, many of us are waiting for updates regarding the support for the current software factories such as Web Service Software Factory, Smart Client Software Factory and Web Client Software Factory for Visual Studio 2008.

I've already mentioned in an earlier post that currently there is not support for those factories in Visual Studio 2008, since it broke some DTE interfaces, and therefore it is not fully backward compatible.

Recently, the patterns and practices team has updates their Upcoming Releases Page to include the next updates to those factories. According to this page, Enterprise Library, Web Client Software Factory and Web Service Software Factory will have new releases in February 2008, around the time Visual Studio 2008 ships. Thus, the Smart Client Software Factory will not have any release planned which means it cannot be used in Visual Studio 2008, since Microsoft is targeting to be the new platform for building composite smart client applications. Although I totally agree that Acropolis is great and will contain the features from CAB, I still think that due to the timeline of Acropolis (At least 1.5 years from now), Microsoft must update CAB and the Smart Client Application Block to support Visual Studio 2008.

I am currently in a project that decided to use WPF as its presentation technology, and is currently considering using CAB and the Smart Client Application Block. In the mean time, they are also considering moving to Visual Studio 2008 as soon as it ships, and this can be a good reason to stay in Visual Studio 2005.

So, If anyone in Microsoft patterns & practices is reading this post, Please, think about it again, or at least point the community on what is required in order to do it.

74% Starscream

Just saw that mike has taken the Transformers quiz and decided to take it myself.

starscream

Take the Transformers Quiz

Which transformer are you?

Service Factory v3 - New Community Drop on CodePlex

Service Factory v3 - New Community Drop on CodePlex

Service Factory v3

Build 117 alpha of Service Factory v3 is available for download from Community Page of Service Factory on CodePlex.

In order to get started with this new release, go through the documentation of this release. It contains instructions for setting up the factory for your development environment, and also contains an introductory walkthrough that helps you understand how to benefit from the factory.

The team is looking for your feedback, as the opportunity to make a difference before the final release is closing. If you have any feedback, please answer these questions, as I did.

Regarding the compatibility of this release - this release is compatible with Visual Studio 2005. It works with both GAX 1.2 and 1.3, but with each one of them there are known issues that will be addressed in the next release.

Enjoy!

עכשיו זה רשמי - אני מפורסם!

אתר מיקרוסופט ישראל מפנה לבלוג שלי... (לפוסט שכתבתי בימים האחרונים).

Microsoft Israel

רוצים גם?

How To: Build an Add-In using System.AddIn

How To: Build an Add-In using System.AddIn

When you want to build an extensible application, that dynamically loads add-ins into it, you face some challenges such as discovering, activating and managing the lifetime of the add-ins. With the new System.AddIn Framework that ships with Visual Studio 2008, this tasks becomes much easier. 

This post is a step by step guide for building a *very* simple add-in using the new System.AddIn Framework. I will guide you through building a Console Application that actives add-ins and runs them. In later posts I will discuss how to version the host and add-ins separately, talk about less trivial scenarios and provide feedback about this process which I hope the team will collect.

Create the Solution

Create a new solution in Visual Studio 2008, and create the following structure using solution folders.

System.AddIn Build

Create the Host Side

Host View

The Host View defines the way the host sees the add-ins.

Create the Host View of the add-in. Create a Class Library under the Host Side Solution Folder.

System.AddIn Build

Set the output directory of the host application project to be ..\output instead of bin\debug. This is because the discovery and pipeline building phases require a certain directory structure that will be discussed later.

Create a class for the simple add-in host view. This class is an abstract class with the operations that the host will call on the add-in.

/// <summary>

/// The host view defines the how the host sees the add-in

/// </summary>

public abstract class SimpleAddInHostView

{

    public abstract string SayHello(string name);

}

Host application

The host application actives and manages the lifetime of the add-ins.

Create the Host application as a Console Application under the Host Side Solution Folder.

System.AddIn Build

Set the output folder of the host view project to be ..\output\

Set this project as start up project.

Add references to System.AddIn and System.AddIn.Contract assemblies. Also add a reference to the Host.View project.

In the Main method of the host application, write the following code:

static void Main(string[] args)

{

    // Set the add-ins discovery root directory to be the current directory

    string addinRoot = Environment.CurrentDirectory;

 

    // Rebuild the add-ins cache and pipeline components cache.

    AddInStore.Rebuild(addinRoot);

 

    // Get registerd add-ins of type SimpleAddInHostView

    Collection<AddInToken> addins = AddInStore.FindAddIns(typeof(SimpleAddInHostView), addinRoot);

 

    foreach (AddInToken addinToken in addins)

    {

        // Activate the add-in

        SimpleAddInHostView addinInstance =

           addinToken.Activate<SimpleAddInHostView>(AddInSecurityLevel.Internet);

 

        // Use the add-in

        Console.WriteLine(String.Format("Add-in {0} Version {1}",

             addinToken.Name, addinToken.Version));

        Console.WriteLine(addinInstance.SayHello("Guy"));

    }

}

This code snippet rebuilds the cache of the add-ins store and the pipeline components. Then, the host is looking for add-ins of type SimpleAddIn and uses them.

Create the Add-In Side

Add-In Views

The add-in views define the base class for the add-ins. It is the way the add-in receives the calls from the host.

Create the AddIn Views project as a Class Library under the AddIn Side Solution Folder.

System.AddIn Build

Set the output folder of the host view project to be ..\output\AddInViews\

Add references to System.AddIn and System.AddIn.Contract assemblies.

Create a class for the simple add-in view. This class is an abstract class with the operations that the host will call on the add-in. This class is decorated with the AddInBase attribute. This attribute is important when building the pipeline.

/// <summary>

/// The add-in view defines the how the add-in sees how it is

/// called by the host

/// </summary>

[AddInBase]

public abstract class SimpleAddInView

{

    public abstract string SayHello(string name);

}

Add-In Implementation

The host can activate many add-ins. Each add-in derives from the add-in view and is deployed in a separate directory.

Create each Add-In Implementation project as a Class Library under the AddIn Side\AddIns Solution Folder. In the samples I created 2 add-ins.

System.AddIn Build

Set the output folder of the host view project to be ..\output\AddIns\<AddInName>. (For example: ..\output\first\ and ..\output\second). 

For each add-in implementation project, add references to System.AddIn and System.AddIn.Contract assemblies. Also add a reference to the AddIn.View project, but make sure you set Copy Local = False.

Implement the add-ins. Create a class that derives from the AddIn View class (SimpleAddInView), and decorated with the AddIn attribute. This attribute specifies the matedata of the add-in.

[AddIn("My First Add-In",

    Version="1.0.0.0",

    Description="Description of My First Add-In",

    Publisher="Guy Burstein")]

public class FirstAddIn : SimpleAddInView

{

    public override string SayHello(string name)

    {

        return "Hi, " + name;

    }

}

Create the Pipeline Components

Usually, we prefer that the add-ins will be activated isolated in a separate AppDomain for better sandboxing and robustness of the host application. This isolation brings the need for inter-appdomain communication that is addressed by building the appropriate pipeline between the host and the add-in.

The Contract

The minimal interface between the host and the add-in is expressed by a contract. This contract cannot be versioned.

Create the Contract project as a Class Library under the Contracts Solution Folder.

System.AddIn Build

Set the output folder of the host view project to be ..\output\Contracts.

Add references to System.AddIn and System.AddIn.Contract assemblies.

Create an interface for the contract. This interface contain the operations that the host will call on the add-in.

/// <summary>

/// This interface defines the contract between the host and the add-in, and

/// therefore cannot be versioned.

/// </summary>

[AddInContract]

public interface ISimpleContract : IContract

{

    string SayHello(string name);

}

Notice that this interface derives from IContract interface and is decorated by the AddInContract attribute.

Host Side Adapter

The host side adapter is responsible for converting from the contract to the host view. This way, the host view has no dependency on the contract and can be versioned independently.

In this sample, the host calls methods on the add-in, and not the opposite. Therefore, we only need an adapter from the Contract to the Host View.

Create the Host Adapters project as a Class Library under the Host Side Solution Folder.

System.AddIn Build

Set the output folder of the host view project to be ..\output\HostSideAdapters.

Add references to System.AddIn and System.AddIn.Contract assemblies. Also add a reference to Host.View and Contracts projects, but make sure you set Copy Local = False.

Implement the adapter. This adapter derives from the host view, and as an implementation calls method on an instance referenced by the contract interface.

/// <summary>

/// This class converts a contract instance to the host view

/// </summary>

[HostAdapter]

public class SimpleContractToHostViewAdapter : SimpleAddInHostView

{

    private ISimpleContract _contract;

    private ContractHandle _handle;

 

    public SimpleContractToHostViewAdapter(ISimpleContract contract)

    {

        this._contract = contract;

        _handle = new ContractHandle(contract);

    }

 

    public override string SayHello(string name)

    {

        return this._contract.SayHello(name);

    }

}

Notice that the constructor initiates an instance of ContractHandle which helps the lifetime management of the add-in.

Add In Adapter

The add-in side adapter is responsible for converting from the add-in view to the contract. This way, the add-in view has no dependency on the contract and can be versioned independently.

In this sample, the host calls methods on the add-in, and not the opposite. Therefore, we only need an adapter from the Add-In View to the contract.

Create the Add-In Adapters project as a Class Library under the AddIn Side Solution Folder.

System.AddIn Build

Set the output folder of the host view project to be ..\output\AddInSideAdapters.

Add references to System.AddIn and System.AddIn.Contract assemblies. Also add a reference to AddIn.View and Contracts projects, but make sure you set Copy Local = False.

Implement the adapter. This adapter derives from the BaseContract, implements the contract, and as an implementation calls method on an instance of the add-in view.

/// <summary>

/// This class converts an add-in view to the contract

/// </summary>

[AddInAdapter]

public class SimpleAddInViewToContractAdapter : ContractBase, ISimpleContract

{

    private SimpleAddInView _view;

 

    public SimpleAddInViewToContractAdapter(SimpleAddInView view)

    {

        this._view = view;

    }

 

    public string SayHello(string name)

    {

        return this._view.SayHello(name);

    }

}

Running the Sample

You can download the sample project that contain the simple add-in created with System.AddIn in this post. Running this sample, you should see this result:

System.AddIn Build

Additional Resources

Enjoy!

System.AddIn.Pipeline.LifetimeTokenHandle renamed to ContractHandle

System.AddIn.Pipeline.LifetimeTokenHandle renamed to ContractHandle

System.AddIn.Pipeline.LifetimeTokenHandle ContractHandle I am playing with the new System.AddIn capabilities that are part of the .Net Framework 3.5, and finding it great. I have developed a smart client application in the past that had to face the dynamic loading of modules and seeing the new API and the problems this technology solves - I am very happy to get started with it.

I started by reading the two introductory articles in MSDN Magazine: .NET Application Extensibility - Part 1 and .NET Application Extensibility - Part 2, by Jack Gudenkauf and Jesse Kaplan.

In those articles, the samples project is an extensible calculator that loads add-ins using the new API. When trying to play with this samples project in Visual Studio 2008 Beta 2, it won't compile, since the class System.AddIn.Pipeline.LifetimeTokenHandle renamed to ContractHandle.

Just replace the following code (in CalculatorContractToViewHostAdapter.cs):

[System.AddIn.Pipeline.HostAdapterAttribute()]

public class CalculatorContractToViewHostAdapter : CalculatorContractsHAV.Calculator {

 

    private CalculatorContracts.ICalculatorContract _contract;

 

    private System.AddIn.Pipeline.LifetimeTokenHandle _handle;

 

    public CalculatorContractToViewHostAdapter(CalculatorContracts.ICalculatorContract contract) {

        _contract = contract;

        _handle = new System.AddIn.Pipeline.LifetimeTokenHandle(contract);

    }

 

    ...

}

To this code:

[System.AddIn.Pipeline.HostAdapterAttribute()]

public class CalculatorContractToViewHostAdapter : CalculatorContractsHAV.Calculator {

 

    private CalculatorContracts.ICalculatorContract _contract;

 

    private System.AddIn.Pipeline.ContractHandle _handle;

 

    public CalculatorContractToViewHostAdapter(CalculatorContracts.ICalculatorContract contract) {

        _contract = contract;

        _handle = new System.AddIn.Pipeline.ContractHandle(contract);

    }

 

    ...

}

Enjoy!

WF, WCF and WCS Samples for Visual Studio 2008 Beta 2

WF, WCF and WCS Samples for Visual Studio 2008 Beta 2

WF, WCF and WCS Samples for Visual Studio 2008 Beta 2 A refresh of the samples for Windows Communication Foundation (WCF), Windows Workflow Foundation (WF) and Windows CardSpace (WCS) is available for download here. These samples are based on the .Net Framework 3.5 and were recently updated to work with Visual Studio 2008 Beta 2.

Enjoy!

Using WF Rules Engine without any Workflow

Using WF Rules Engine without any Workflow

WF Rules Engine Customer often ask me: "If all I need is the WF Rules Engine - why do I have to use Windows Workflow Foundation?"

There is something very important to be clear about - The WF Rules Engine is although a part the the technology called Windows Workflow Foundation, but it can be used without being hosted inside a business process that was built with Windows Workflow Foundation.

The WF Rules Engine has it own API that allows developers to integrate rules capabilities into their applications. It also has many extensibility points for building custom actions, conditions and more.

In the pas I've written several posts about it:

Enjoy!

GAT/GAX July CTP, but no Software Factories

GAT/GAX July CTP, but no Software Factories

The patterns & practices team has released the July 2007 CTP of Guidance Automation Toolkit and Guidance Automation Extensions. It has only minor updates from the previous February CTP, but the big news about it is the support for Visual Studio 2008 (Beta 2).

Great news? not so much...

Visual Studio 2008 has broken some of the DTE interfaces, and therefore it is not fully backward compatible. This means that none of the existing Software Factories can work on Visual Studio 2008.
According to p&p, there are currently no plans to apply these changes and redeploy the factories, but after Visual Studio 2008 is released, they will re-evaluate the amount and priority of this work and decide what's next.

Enjoy!

IOException: Cannot locate resource app.xaml - WPF in Visual Studio 2008 Beta 2

IOException: Cannot locate resource app.xaml -WPF in Visual Studio 2008 Beta 2

I tried to convert some WPF applications from Visual Studio 2005 to Visual Studio 2008 (Beta 2). The conversion went all fine, but when I started debugging this application, I received an IOException: Cannot locate resource app.xaml:

IOException: Cannot locate resource app.xaml IOException: Cannot locate resource 'app.xaml'

The solution I found for this issue is to remove the Custom Tool from the file properties and setting it back to MSBuild:Compile.

IOException: Cannot locate resource app.xaml

I hope this workaround works for you as it worked for me. If you have any other solution, I'd love to hear!

Update (August 8th, 2007) via WPF MSDN Forum: This is a bug. It seems to happen on WPF projects created using VS2005 then converted to VS 2008 Beta2. The team is working on fixing this bug for the final release.

Enjoy!