Monthly Archives: February 2006

Proxy factory with Dynamic Proxy

In this post Pablo explains how to build a proxy factory similar to FactoryChannel in WCF. Here another implementation using DynamicProxy from Castle Project. The main advantage is that it is not necessary that the parameters of the methods of the interface implement MarshalByRefObject (if the parameters are not value types).

using System;
using Castle.DynamicProxy;

public class MyProxy<T> where T : class
public MyProxy( ) { }

public T BuildProxy( )
ProxyGenerator generator = new ProxyGenerator( );

      object proxy = generator.CreateProxy( typeof( T ), new Interceptor( ), null );

      return proxy as T;

public class Interceptor
public object Intercept( IInvocation invocation, params object[] args )
Console.WriteLine( “Calling to the method:” );
Console.WriteLine( “\Name: {0}”, invocation.Method.Name );

      //Place remote service call here
return null;

public class Factory<T>
public Factory( ) { }

   public T Create( )
MyProxy<IMyService> proxy = new MyProxy<IMyService>( );
return proxy.BuildProxy( );

public interface IMyService
void HelloWorld( string message );

public class Program
static void Main(string[] args)
Factory<IMyService> factory = new Factory<IMyService>( );
IMyService service = factory.Create( );
service.HelloWorld( “Rodolfo” );

Visual Studio Setup and Deployment Project, Unattended installation and Custom Properties

When execute an installer made with Visual Studio in the following way:

msiexec /i ProgramInstaller.msi /q TARGETDIR=C:\Program CUSTOMPROPERTY1=”SomeValue”

The custom property CUSTOMPROPERTY1 didnt’t take the value “SomeValue”. After look at the log of the installation (generated with msiexe /log) I saw that Visual Studio always generates a custom action for each property to assign the default value. These custom actions (that have the name CustomTextA_SetProperty_EDITx) are excecute after Windows Installer assigns the properties with the values of the parameters. The solution was eliminated those custom actions, first using Orca and then with this script:

Option Explicit

Dim WI, DB, DelCustom, DelCustom2
Dim Path_MSI_File
Const msiOpenDatabaseModeDirect = 2

Set WI = CreateObject(“WindowsInstaller.Installer”): CheckError
Path_MSI_File = ” “

Path_MSI_File = Wscript.Arguments(0)
Set DB = WI.OpenDatabase(Path_MSI_File,msiOpenDatabaseModeDirect):CheckError

‘Remove VS Custom Actions
Set DelCustom = DB.OpenView(“Delete From CustomAction WHERE `Action`=’CustomTextA_SetProperty_EDIT1′”):CheckError
DelCustom.Execute : CheckError

Set DelCustom2 = DB.OpenView(“Delete From InstallUISequence WHERE `Action`=’CustomTextA_SetProperty_EDIT1′”):CheckError
DelCustom2.Execute : CheckError

Set WI = Nothing
Wscript.Quit 0

Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & ” “ & Hex(Err) & “: “ & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub

Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub

WS-Compression for WSE 3

I had received some mails asking me for a version of WS-Compression for WSE 3, and here is finally!
The code includes a complete example of use.

%d bloggers like this: