示例#1
0
        public string OriginalAssemblyFile(string file)
        {
            string dir = IO.Path.GetDirectoryName(IO.Path.GetFullPath(file));

            System.Reflection.Assembly asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a =>
            {
                try
                {
                    return(a.Location.SamePathAs(file)); //some domain assemblies may throw when accessing .Locatioon
                }
                catch
                {
                    return(false);
                }
            });

            if (asm == null)
            {
                asm = System.Reflection.Assembly.ReflectionOnlyLoadFrom(file);
            }

            // for example 'setup.cs.dll' vs 'setup.cs.compiled'
            var name = asm.ManifestModule.ScopeName;

            return(IO.Path.Combine(dir, name));
        }
示例#2
0
        public string OriginalAssemblyFile(string file)
        {
            string dir = IO.Path.GetDirectoryName(IO.Path.GetFullPath(file));

            System.Reflection.Assembly asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a =>
            {
                try
                {
                    return(a.Location.SamePathAs(file)); //some domain assemblies may throw when accessing .Locatioon
                }
                catch
                {
                    return(false);
                }
            });

            if (asm == null)
            {
                asm = System.Reflection.Assembly.ReflectionOnlyLoadFrom(file);
            }

            var name = asm.ManifestModule.ScopeName;

            if (Path.GetExtension(name) != Path.GetExtension(file))
            {
                name = Path.GetFileNameWithoutExtension(name) + Path.GetExtension(file);
            }

            return(IO.Path.Combine(dir, name));
        }