コード例 #1
0
ファイル: RegCommand.cs プロジェクト: formist/LinkMe
        protected static bool Register(string fullPath)
        {
            // It may be a .NET DLL or a COM dll. Try .NET first.

            Assembly assembly = null;

            try
            {
                // Use LoadFile since the assembly is just being examined and not executed.

                assembly = Assembly.LoadFile(fullPath);
            }
            catch (System.BadImageFormatException)
            {
            }

            // Check based on whether it is an assembly or not.

            if (assembly != null)
            {
                if (ComUtil.CanRegisterForInterop(assembly))
                {
                    ComUtil.RegisterForInterop(assembly);
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public string RegisterDll(string fullPath)
        {
            // It may be a .NET DLL or a COM dll. Try .NET first.

            Assembly assembly = null;

            try
            {
                // Use LoadFile since the assembly is just being examined and not executed.

                assembly = Assembly.LoadFile(fullPath);
            }
            catch (System.BadImageFormatException)
            {
            }

            if (assembly != null)
            {
                // If needed register the assembly for COM interop.

                if (ComUtil.CanRegisterForInterop(assembly))
                {
                    ComUtil.RegisterForInterop(assembly);
                    return(string.Format(Messages.RegisteredForInterop, fullPath));
                }
            }
            else
            {
                // Try registering the file as a COM DLL.

                //RegisterUtil.RegisterDll(fullPath);
                //return string.Format(Resources.Messages.RegisteredForCom, fullPath);
            }

            return(null);
        }