Esempio n. 1
0
        private void LoadAssembly(string fullPath)
        {
            if (fullPath == null)
            {
                throw new ArgumentNullException("fullPath");
            }

            try
            {
                var assembly = Assembly.LoadFrom(fullPath);
                BuildManager.AddReferencedAssembly(assembly);
                CompositionProvider.AddAssembly(assembly);
                _assemblies.Add(assembly);
            }
            catch (Exception err)
            {
                Trace.TraceWarning("Failed to load " + fullPath + ".", err);

                var loaderEx = err as ReflectionTypeLoadException;
                if (loaderEx != null)
                {
                    foreach (var exception in loaderEx.LoaderExceptions)
                    {
                        Trace.TraceWarning(string.Format("Loader exception for file '{0}'.", fullPath), exception);
                    }
                }

                throw;
            }
        }
Esempio n. 2
0
        internal Assembly TryLoadAssemblyByName(string fileName, bool throwOnError = false)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                if (throwOnError)
                {
                    throw new ArgumentNullException("fileName");
                }

                return(null);
            }

            var fullPath = Path.Combine(_path, fileName);

            if (!File.Exists(fullPath))
            {
                if (throwOnError)
                {
                    throw new FileNotFoundException("file not found", fullPath);
                }

                return(null);
            }

            try
            {
                var assembly = Assembly.LoadFrom(fullPath);
                BuildManager.AddReferencedAssembly(assembly);
                CompositionProvider.AddAssembly(assembly);
                _assemblies.Add(assembly);
                return(assembly);
            }
            catch (Exception err)
            {
                Trace.TraceWarning("Failed to load " + fullPath + ".", err);

                var loaderEx = err as ReflectionTypeLoadException;
                if (loaderEx != null)
                {
                    foreach (var exception in loaderEx.LoaderExceptions)
                    {
                        Trace.TraceWarning(string.Format("Loader exception for file '{0}'.", fullPath), exception);
                    }
                }

                if (throwOnError)
                {
                    throw;
                }

                return(null);
            }
        }
Esempio n. 3
0
        protected void Application_Start()
        {
            // Initialize membership and role providers
            WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "Id", "Account", false);

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            CompositionProvider.AddAssembly(GetType().Assembly);
            CompositionProvider.AddAssembly(typeof(IActionVerb).Assembly);
        }