[Mono-list] Possible Bug?

Christian Gross mailing@devspace.com
Thu, 28 Apr 2005 00:17:26 +0200


Consider the following class declaration.

internal class PluginBase {
    private string _path;

    public PluginBase( string path ) {
        _path = path;
    }

    public instanceType CreateInstance<instanceType>( 
        string assemblyidentifier, 
        string typeidentifier ) where instanceType : class
            where instanceType : class {
            Assembly assembly;
            assembly = Assembly.Load( AssemblyName.GetAssemblyName( _path ) );
            if( assembly != null ) {
                return (assembly.CreateInstance( typeidentifier )) 
                    as instanceType;
            }
        }
    }
}

This code compiles in .NET

When I attempt to compile with Mono from SVN I get the following error.

/Users/cgross/Desktop/projects/oop-using-net-patterns/src/Chap05.TranslationDefinitions/definitions.cs(33)
error CS0077: The as operator should be used with a reference type only
(instanceType is a value type)

Should this not compile?

Thanks

Christian Gross