Exemplo n.º 1
0
        private static Version GetDotNetFrameworkVersion()
        {
            string version = Environment.Version.ToString(2);

            if (version.Equals("2.0"))
            {
                try
                {                 // Try to load a 3.0 assembly.
                    AppDomain.CurrentDomain.Load("System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089");
                    version = "3.0";
                }
                catch (Exception) { }

                try
                {                 // Try to load a 3.5 assembly.
                    AppDomain.CurrentDomain.Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089");
                    version = "3.5";
                }
                catch (Exception) { }

                if (version.Equals("2.0"))
                {
                    // Log info message when app is running at 2.0.
                    string    msg = Properties.Resources.DotNet_3_Or_Higher_Not_Found_Ex_Msg;
                    Exception ex  = new ErrorHandler.CustomExceptions.BusinessException(msg);
                    ErrorHandler.Error.Record(ex);
                    HelperFunctions.PurgeCache();

                    ErrorHandler.Error.Record(ex);
                }
            }

            return(new Version(version));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return a value indicating whether the .NET Framework 3.0 is installed on the current system. This is determined
        /// by invoking a method in the GalleryServerPro.Business.Wpf assembly. This assembly has a reference to
        /// PresentationCore.dll and WindowsBase.dll, both .NET 3.0 assemblies. If the method throws a TargetInvocationException,
        /// we'll assume the framework is not installed.
        /// </summary>
        /// <returns>Returns true if .NET Framework 3.0 is installed; otherwise returns false.</returns>
        /// <remarks>The technique used here is fairly fragile. Any exception thrown by the invoked method is received as a
        /// TargetInvocationException, even if .NET 3.0 is installed. However, this was perceived to be the best available
        /// technique.
        /// </remarks>
        private static bool DetermineIfDotNet3IsInstalled()
        {
            bool isDotNet3Installed = false;

            //try
            //{
            //  GalleryServerPro.Business.Wpf.WpfMetadataExtractor.AddWpfBitmapMetadata(String.Empty, null);
            //  isDotNet3Installed = true;
            //}
            //catch (Exception ex)
            //{
            //  GalleryServerPro.ErrorHandler.Error.Record(ex, System.Diagnostics.EventLogEntryType.Information);
            //}

            System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("GalleryServerPro.Business.Wpf");

            if (assembly == null)
            {
                return(false);
            }

            // Get reference to static WpfMetadataExtractor.AddWpfBitmapMetadata() method.
            Type[] parmTypes = new Type[2];
            parmTypes[0] = typeof(string);
            parmTypes[1] = typeof(GalleryServerPro.Business.Interfaces.IGalleryObjectMetadataItemCollection);
            Type metadataExtractor = assembly.GetType("GalleryServerPro.Business.Wpf.WpfMetadataExtractor");

            System.Reflection.MethodInfo addMetadataMethod = metadataExtractor.GetMethod("AddWpfBitmapMetadata", parmTypes);

            // Prepare parameters to pass to WpfMetadataExtractor.AddWpfBitmapMetadata() method.
            object[] parameters = new object[2];
            parameters[0] = String.Empty;
            parameters[1] = null;

            try
            {
                addMetadataMethod.Invoke(null, parameters);
                isDotNet3Installed = true;
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                string    msg = GalleryServerPro.Business.Properties.Resources.DotNet_3_Or_Higher_Not_Found_Ex_Msg;
                Exception ex2 = new ErrorHandler.CustomExceptions.BusinessException(msg, ex);
                ErrorHandler.Error.Record(ex2);
                HelperFunctions.PurgeCache();

                GalleryServerPro.ErrorHandler.Error.Record(ex);
            }

            return(isDotNet3Installed);
        }
Exemplo n.º 3
0
		/// <summary>
		/// Return a value indicating whether the .NET Framework 3.0 is installed on the current system. This is determined
		/// by invoking a method in the GalleryServerPro.Business.Wpf assembly. This assembly has a reference to 
		/// PresentationCore.dll and WindowsBase.dll, both .NET 3.0 assemblies. If the method throws a TargetInvocationException,
		/// we'll assume the framework is not installed.
		/// </summary>
		/// <returns>Returns true if .NET Framework 3.0 is installed; otherwise returns false.</returns>
		/// <remarks>The technique used here is fairly fragile. Any exception thrown by the invoked method is received as a
		/// TargetInvocationException, even if .NET 3.0 is installed. However, this was perceived to be the best available
		/// technique.
		/// </remarks>
		private static bool DetermineIfDotNet3IsInstalled()
		{
			bool isDotNet3Installed = false;

			//try
			//{
			//  GalleryServerPro.Business.Wpf.WpfMetadataExtractor.AddWpfBitmapMetadata(String.Empty, null);
			//  isDotNet3Installed = true;
			//}
			//catch (Exception ex)
			//{
			//  GalleryServerPro.ErrorHandler.Error.Record(ex, System.Diagnostics.EventLogEntryType.Information);
			//}

			System.Reflection.Assembly assembly = System.Reflection.Assembly.Load("GalleryServerPro.Business.Wpf");

			// Get reference to static WpfMetadataExtractor.AddWpfBitmapMetadata() method.
			Type[] parmTypes = new Type[2];
			parmTypes[0] = typeof(string);
			parmTypes[1] = typeof(GalleryServerPro.Business.Interfaces.IGalleryObjectMetadataItemCollection);
			Type metadataExtractor = assembly.GetType("GalleryServerPro.Business.Wpf.WpfMetadataExtractor");
			System.Reflection.MethodInfo addMetadataMethod = metadataExtractor.GetMethod("AddWpfBitmapMetadata", parmTypes);

			// Prepare parameters to pass to WpfMetadataExtractor.AddWpfBitmapMetadata() method.
			object[] parameters = new object[2];
			parameters[0] = String.Empty;
			parameters[1] = null;

			try
			{
				addMetadataMethod.Invoke(null, parameters);
				isDotNet3Installed = true;
			}
			catch (System.Reflection.TargetInvocationException ex)
			{
				string msg = GalleryServerPro.Business.Properties.Resources.DotNet_3_Or_Higher_Not_Found_Ex_Msg;
				Exception ex2 = new ErrorHandler.CustomExceptions.BusinessException(msg, ex);
				ErrorHandler.Error.Record(ex2);
				HelperFunctions.PurgeCache();

				GalleryServerPro.ErrorHandler.Error.Record(ex);
			}

			return isDotNet3Installed;
		}