/*
         * Create an object in the runtime appdomain
         */

        public IRegisteredObject CreateObject(Type type, bool failIfExists)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            EnsureHostCreated();
            Debug.Assert(_appId != null);
            Debug.Assert(_appHost != null);

            _host.RegisterAssembly(type.Assembly.FullName, type.Assembly.Location);

            ApplicationManager appManager = ApplicationManager.GetApplicationManager();

            return(appManager.CreateObjectInternal(_appId, type, _appHost, failIfExists, _hostingParameters));
        }