Esempio n. 1
0
        private object LoadPluginOnUiThread(PluginStartupInfo startupInfo)
        {
            _log.Debug("Creating plugin on UI thread");

            var assembly  = startupInfo.AssemblyName;
            var mainClass = startupInfo.MainClass;

            try
            {
                var obj = PluginCreator.CreatePlugin(startupInfo.AssemblyName, startupInfo.MainClass, _host);
                _log.Debug("Created local plugin class instance");

                var localPlugin = obj as IPlugin;

                if (localPlugin == null)
                {
                    var message = string.Format("Object of type {0} cannot be loaded as plugin " +
                                                "because it does not implement IPlugin interface", mainClass);

                    throw new InvalidOperationException(message);
                }

                var remotePlugin = new RemotePlugin(localPlugin);
                _log.Debug("Created plugin control");
                return(remotePlugin);
            }
            catch (Exception ex)
            {
                var message = String.Format("Error loading type '{0}' from assembly '{1}'. {2}",
                                            mainClass, assembly, ex.Message);

                return(new ApplicationException(message, ex));
            }
        }
Esempio n. 2
0
        private object LoadPluginOnUiThread(PluginStartupInfo startupInfo)
        {
            _log.Debug("Creating plugin on UI thread");

            var assembly = startupInfo.AssemblyName;
            var mainClass = startupInfo.MainClass;

            try
            {
                var obj = PluginCreator.CreatePlugin(startupInfo.AssemblyName, startupInfo.MainClass, _host);
                _log.Debug("Created local plugin class instance");

                var localPlugin = obj as IPlugin;

                if (localPlugin == null)
                {
                    var message = string.Format("Object of type {0} cannot be loaded as plugin " +
                        "because it does not implement IPlugin interface", mainClass);

                    throw new InvalidOperationException(message);
                }

                var remotePlugin = new RemotePlugin(localPlugin);
                _log.Debug("Created plugin control");
                return remotePlugin;
            }
            catch (Exception ex)
            {
                var message = String.Format("Error loading type '{0}' from assembly '{1}'. {2}",
                    mainClass, assembly, ex.Message);

                return new ApplicationException(message, ex);
            }
        }