当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyName.ToString方法代码示例

本文整理汇总了C#中System.Reflection.AssemblyName.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyName.ToString方法的具体用法?C# AssemblyName.ToString怎么用?C# AssemblyName.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.AssemblyName的用法示例。


在下文中一共展示了AssemblyName.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChooseAssemblyName

    public ChooseAssemblyName(AssemblyName assemblyName = null)
    {
      InitializeComponent();

      if (assemblyName != null)
        _assemblyName.Text = assemblyName.ToString();
    }
开发者ID:rsdn,项目名称:nitra,代码行数:7,代码来源:ChooseAssemblyName.xaml.cs

示例2: InitDAD

 public static void InitDAD()
 {
     AppDomain ad = AppDomain.CurrentDomain;
     AssemblyName asmName = new AssemblyName();
     asmName.Name = @"G:\naynish\Pro C# 2010 and the .NET 4 Platform\ReflectionLateBindingAttributeBased\ConsoleApplication1\ConsoleApplication1\bin\Debug\MathLibrary.dll";
     ad.AssemblyLoad += new AssemblyLoadEventHandler(ad_AssemblyLoad);
     Assembly.LoadFrom(asmName.ToString());
 }
开发者ID:naynishchaughule,项目名称:CSharp,代码行数:8,代码来源:ApplicationDomainDemo.cs

示例3: GetGameVersion

        private string GetGameVersion()
        {
            string output = "Version: ";
            try
            {
            #if WINDOWS_PHONE
                Version version = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version;
                return output + version.ToString();
            #endif
            }
            catch
            { }

            //Version for windows
            return output + "1.0.0.1";
        }
开发者ID:krolth,项目名称:RetroPixels,代码行数:16,代码来源:AboutMenuScreen.cs

示例4: LoadExternalModule

 private void LoadExternalModule(string path)
 {
     AssemblyName asmName = new AssemblyName();
     asmName.Name = path;
     Assembly asm = Assembly.LoadFrom(asmName.ToString());
     Type[] arrr = asm.GetTypes();
     foreach (Type item in arrr)
     {
         if (item.IsClass && item.GetInterface("MyApplicationInterface")!= null
             && item.GetCustomAttributes(typeof(AppHooks.MyCustomAttributes), false) != null)
         {
             MyApplicationInterface mai = (MyApplicationInterface)Activator.CreateInstance(item);
             mai.DisplayMessage();
             listBox1.Items.Add(item.FullName);
             LoadAttributes(item);
         }
     }
 }
开发者ID:naynishchaughule,项目名称:CSharp,代码行数:18,代码来源:Form1.cs

示例5: Main

        static void Main(string[] args)
        {
            Console.WriteLine(Fname);
            BasicMath bm = new BasicMath();
            Console.WriteLine("sum = {0}", bm.Add(10.45, 243.39));
            //different ways to create type instance
            //System.Object
            Type t = bm.GetType();
            System.Reflection.MethodInfo mtInfo = t.GetMethod("Add");
            Console.WriteLine("is Add public {0}", mtInfo.IsPublic);

            //typeof
            Type typo = typeof(BasicMath);

            //you don't need compile time info about the type
            //System.Type.GetType (static method)
            try
            {
                // Obtain type information for a type within an external assembly.
                //fully qualified name of the type, friendly name of the assembly
                Type sysType = System.Type.GetType("MathLibrary.BasicMath, MathLibrary", true, false);

                //Obtain type information for a nested class (add + for nested types)
                System.Type.GetType("MathLibrary.BasicMath+Trigonometry, MathLibrary", true, false);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            /*“back tick” character (`) followed by a numerical value that represents
            the number of type parameters*/
            //System.Collections.Generic.List<T>
            Type tInfo = System.Type.GetType("System.Collections.Generic.List`1, mscorlib", true, false);
            RedReflector rdr = new RedReflector();
            rdr.ListMethods(tInfo);
            //rdr.ListProperties(tInfo);
            rdr.ListInterfaces(tInfo);
            rdr.ListStats(tInfo);

            //dynamically loading assembly
            ExternalAssemblyReflector ear = new ExternalAssemblyReflector();
            //ear.DisplayTypesInAsm(Assembly.LoadFrom(@"G:\naynish\Pro C# 2010 and the .NET 4 Platform\ReflectionLateBindingAttributeBased\ConsoleApplication1\MathLibrary\bin\Debug\MathLibrary.dll"));

            String extPath = @"G:\naynish\Pro C# 2010 and the .NET 4 Platform\ReflectionLateBindingAttributeBased\ConsoleApplication1\SimpleEmployee\bin\Debug\SimpleEmployee.dll";
            AssemblyName asmName = new AssemblyName();
            //path including the extension
            asmName.Name = extPath;

            //LoadFrom because the assembly is not in the bin directory of ConsoleApplication1
            ear.DisplayTypesInAsm(Assembly.LoadFrom(asmName.ToString()));

            //loading shared assemblies
            Assembly myAssembly = Assembly.Load(@"System.Windows.Forms, Version = 4.0.0.0, PublicKeyToken = b77a5c561934e089, Culture = """);
            ear.DisplayTypesInSharedAsm(myAssembly);

            AssemblyName customMyAssembly = new AssemblyName();
            customMyAssembly.Name = "CustomLibrary";
            Version v = new Version("1.0.0.0");
            customMyAssembly.Version = v;

            Assembly a = Assembly.Load(customMyAssembly);
            ear.DisplayTypesInAsm(a);
            AttributeBased ab = new AttributeBased();
            //ab.salary; (error on reflecting over this type using C# compiler)

            //reflect over an attributed type
            AssemblyName name = new AssemblyName();
            name.Name = "AttributedEmployeeLibrary";
            Assembly myAttr = Assembly.Load(name);

            Type tp = myAttr.GetType("AttributedEmployeeLibrary.VicePresident");
            Object myInstance = Activator.CreateInstance(tp);
            MethodInfo info = tp.GetMethod("GetFname");
            Console.WriteLine(info.Invoke(myInstance, null));

            Object[] custAttr = tp.GetCustomAttributes(false);
            foreach (var item in custAttr)
            {
                Console.WriteLine(item);
            }

            foreach (Type item in myAttr.GetTypes())
            {
                foreach (object item1 in item.GetCustomAttributes(myAttr.GetType("AttributedEmployeeLibrary.EmployeeDescriptionAttribute"), false))
                {
                    Console.WriteLine((myAttr.GetType("AttributedEmployeeLibrary.EmployeeDescriptionAttribute").GetProperty("Description")).GetValue(item1,null));
                }
            }
            Console.ReadLine();
        }
开发者ID:naynishchaughule,项目名称:CSharp,代码行数:91,代码来源:Program.cs

示例6: GetAssemblyStrongNames

 public static IEnumerable<string> GetAssemblyStrongNames(AssemblyName assemblyName)
 {
     return GetAssemblyStrongNames(assemblyName.ToString());
 }
开发者ID:ericschultz,项目名称:xaml-reference-fixifier,代码行数:4,代码来源:GAC.cs

示例7: Case2_ToString

 public void Case2_ToString()
 {
     AssemblyName n = new AssemblyName("Foo");
     Assert.True(n.ToString().StartsWith("Foo"));
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:5,代码来源:AssemblyName_MethodTests.cs

示例8: ResolveDependentAssemblies

        /// <summary>
        /// Sets up a reflection-only assembly-resolve-handler to handle loading dependent assemblies during reflection.
        /// </summary>
        /// <param name="inputFiles">List of input files which include non-GAC dependent assemblies.</param>
        /// <param name="inputDir">Directory to auto-locate additional dependent assemblies.</param>
        /// <remarks>
        /// Also searches the assembly's directory for unspecified dependent assemblies, and adds them
        /// to the list of input files if found.
        /// </remarks>
        private static void ResolveDependentAssemblies(IDictionary<string, string> inputsMap, string inputDir)
        {
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args)
            {
                AssemblyName resolveName = new AssemblyName(args.Name);
                Assembly assembly = null;

                // First, try to find the assembly in the list of input files.
                foreach (string inputFile in inputsMap.Values)
                {
                    string inputName = Path.GetFileNameWithoutExtension(inputFile);
                    string inputExtension = Path.GetExtension(inputFile);
                    if (String.Equals(inputName, resolveName.Name, StringComparison.OrdinalIgnoreCase) &&
                        (String.Equals(inputExtension, ".dll", StringComparison.OrdinalIgnoreCase) ||
                         String.Equals(inputExtension, ".exe", StringComparison.OrdinalIgnoreCase)))
                    {
                        assembly = MakeSfxCA.TryLoadDependentAssembly(inputFile);

                        if (assembly != null)
                        {
                            break;
                        }
                    }
                }

                // Second, try to find the assembly in the input directory.
                if (assembly == null && inputDir != null)
                {
                    string assemblyPath = null;
                    if (File.Exists(Path.Combine(inputDir, resolveName.Name) + ".dll"))
                    {
                        assemblyPath = Path.Combine(inputDir, resolveName.Name) + ".dll";
                    }
                    else if (File.Exists(Path.Combine(inputDir, resolveName.Name) + ".exe"))
                    {
                        assemblyPath = Path.Combine(inputDir, resolveName.Name) + ".exe";
                    }

                    if (assemblyPath != null)
                    {
                        assembly = MakeSfxCA.TryLoadDependentAssembly(assemblyPath);

                        if (assembly != null)
                        {
                            // Add this detected dependency to the list of files to be packed.
                            inputsMap.Add(Path.GetFileName(assemblyPath), assemblyPath);
                        }
                    }
                }

                // Third, try to load the assembly from the GAC.
                if (assembly == null)
                {
                    try
                    {
                        assembly = Assembly.ReflectionOnlyLoad(args.Name);
                    }
                    catch (FileNotFoundException)
                    {
                    }
                }

                if (assembly != null)
                {
                    if (String.Equals(assembly.GetName().ToString(), resolveName.ToString()))
                    {
                        log.WriteLine("    Loaded dependent assembly: " + assembly.Location);
                        return assembly;
                    }
                    else
                    {
                        log.WriteLine("    Warning: Loaded mismatched dependent assembly: " + assembly.Location);
                        log.WriteLine("      Loaded assembly   : " + assembly.GetName());
                        log.WriteLine("      Reference assembly: " + resolveName);
                    }
                }
                else
                {
                    log.WriteLine("    Error: Dependent assembly not supplied: " + resolveName);
                }

                return null;
            };
        }
开发者ID:zooba,项目名称:wix3,代码行数:93,代码来源:MakeSfxCA.cs

示例9: GetFullNameAndToString_AreEquivalentAndDoNotPreserveArchitecture

        public void GetFullNameAndToString_AreEquivalentAndDoNotPreserveArchitecture()
        {
            foreach (KeyValuePair<string, ProcessorArchitecture> pair in GetValidNameValuePairs())
            {
                string originalFullName = "Test, Culture=en-US, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=" + pair.Key;
                string expectedSerializedFullName = "Test, Culture=en-US, PublicKeyToken=b77a5c561934e089";

                var assemblyName = new AssemblyName(originalFullName);

                Assert.Equal(expectedSerializedFullName, assemblyName.FullName);
                Assert.Equal(expectedSerializedFullName, assemblyName.ToString());
            }
        }
开发者ID:smaclell,项目名称:corefx,代码行数:13,代码来源:AssemblyName_ProcessorArchitectureTests.cs

示例10: Constructor1_ProcessorArchitecture

	[Category ("NotWorking")] // bug #351708
	public void Constructor1_ProcessorArchitecture ()
	{
		const string assemblyName = "TestAssembly";

		an = new AssemblyName (assemblyName + ", ProcessorArchitecture=X86");
		Assert.IsNull (an.CodeBase, "CodeBase");
		Assert.IsNull (an.CultureInfo, "CultureInfo");
		Assert.IsNull (an.EscapedCodeBase, "EscapedCodeBase");
		Assert.AreEqual (AssemblyNameFlags.None, an.Flags, "Flags");
		Assert.AreEqual ("TestAssembly", an.FullName, "FullName");
		Assert.AreEqual (AssemblyHashAlgorithm.None, an.HashAlgorithm, "HashAlgorithm");
		Assert.IsNull (an.KeyPair, "KeyPair");
		Assert.AreEqual (assemblyName, an.Name, "Name");
		Assert.AreEqual (ProcessorArchitecture.X86, an.ProcessorArchitecture, "PA");
		Assert.IsNull (an.Version, "Version");
		Assert.AreEqual (AssemblyVersionCompatibility.SameMachine, 
			an.VersionCompatibility, "VersionCompatibility");
		Assert.IsNull (an.GetPublicKey (), "GetPublicKey");
		Assert.IsNull (an.GetPublicKeyToken (), "GetPublicKeyToken");
		Assert.AreEqual ("TestAssembly", an.ToString (), "ToString");

		an = new AssemblyName (assemblyName + ", ProcessorArchitecture=mSiL");
		Assert.AreEqual (ProcessorArchitecture.MSIL, an.ProcessorArchitecture, "PA: MSIL");

		an = new AssemblyName (assemblyName + ", ProcessorArchitecture=AmD64");
		Assert.AreEqual (ProcessorArchitecture.Amd64, an.ProcessorArchitecture, "PA: Amd64");

		an = new AssemblyName (assemblyName + ", ProcessorArchitecture=iA64");
		Assert.AreEqual (ProcessorArchitecture.IA64, an.ProcessorArchitecture, "PA: IA64");
	}
开发者ID:wamiq,项目名称:debian-mono,代码行数:31,代码来源:AssemblyNameTest.cs

示例11: ReferenceMatchesDefinitionEx

 private static bool ReferenceMatchesDefinitionEx(AssemblyName reference, AssemblyName definition)
 {
     #if __MonoCS__
     return string.Equals(reference.ToString(), definition.ToString(), StringComparison.OrdinalIgnoreCase);
     #else
     return AssemblyName.ReferenceMatchesDefinition(reference, definition);
     #endif
 }
开发者ID:ryansroberts,项目名称:RazorMachine,代码行数:8,代码来源:AppDomainExtension.cs

示例12: Serialization_WithoutStrongName

	public void Serialization_WithoutStrongName ()
	{
		an = new AssemblyName ();
		an.CodeBase = "http://www.test.com/test.dll";
		an.CultureInfo = CultureInfo.InvariantCulture;
		an.Flags = AssemblyNameFlags.None;
		an.HashAlgorithm = AssemblyHashAlgorithm.SHA1;
		an.KeyPair = null;
		an.Name = "TestAssembly2";
		an.Version = new Version (1, 5, 0, 0);
		an.VersionCompatibility = AssemblyVersionCompatibility.SameMachine;

		MemoryStream ms = new MemoryStream ();
		BinaryFormatter bf = new BinaryFormatter ();
		bf.Serialize (ms, an);

		// reset position of memorystream
		ms.Position = 0;

		// deserialze assembly name
		AssemblyName dsAssemblyName = (AssemblyName) bf.Deserialize (ms);

		// close the memorystream
		ms.Close ();

		// compare orginal and deserialized assembly name
		Assert.AreEqual (an.CodeBase, dsAssemblyName.CodeBase, "CodeBase");
		Assert.AreEqual (an.CultureInfo, dsAssemblyName.CultureInfo, "CultureInfo");
		Assert.AreEqual (an.Flags, dsAssemblyName.Flags, "Flags");
		Assert.AreEqual (an.HashAlgorithm, dsAssemblyName.HashAlgorithm, "HashAlgorithm");
		Assert.AreEqual (an.Name, dsAssemblyName.Name, "Name");
		Assert.AreEqual (an.Version, dsAssemblyName.Version, "Version");
		Assert.AreEqual (an.VersionCompatibility, dsAssemblyName.VersionCompatibility, "VersionCompatibility");
		Assert.AreEqual (an.EscapedCodeBase, dsAssemblyName.EscapedCodeBase, "EscapedCodeBase");
		Assert.AreEqual (an.FullName, dsAssemblyName.FullName, "FullName");
		Assert.AreEqual (an.ToString (), dsAssemblyName.ToString (), "ToString");
		Assert.AreEqual (an.GetPublicKey (), dsAssemblyName.GetPublicKey (), "PublicKey");
		Assert.AreEqual (an.GetPublicKeyToken (), dsAssemblyName.GetPublicKeyToken (), "PublicToken");
	}
开发者ID:wamiq,项目名称:debian-mono,代码行数:39,代码来源:AssemblyNameTest.cs

示例13: Clone_Self

	public void Clone_Self ()
	{
		an = Assembly.GetExecutingAssembly ().GetName ();
		AssemblyName clone = (AssemblyName) an.Clone ();

		Assert.AreEqual (an.CodeBase, clone.CodeBase, "CodeBase");
		Assert.AreEqual (an.CultureInfo, clone.CultureInfo, "CultureInfo");
		Assert.AreEqual (an.EscapedCodeBase, clone.EscapedCodeBase, "EscapedCodeBase");
		Assert.AreEqual (an.Flags, clone.Flags, "Flags");
		Assert.AreEqual (an.FullName, clone.FullName, "FullName");
		Assert.AreEqual (an.HashAlgorithm, clone.HashAlgorithm, "HashAlgorithm");
		Assert.AreEqual (an.KeyPair, clone.KeyPair, "KeyPair");
		Assert.AreEqual (an.Name, clone.Name, "Name");
#if NET_2_0
		//Assert.AreEqual (ProcessorArchitecture.MSIL, clone.ProcessorArchitecture, "PA");
#endif
		Assert.AreEqual (an.Version, clone.Version, "Version");
		Assert.AreEqual (an.VersionCompatibility, clone.VersionCompatibility, "VersionCompatibility");
		Assert.AreEqual (an.GetPublicKey (), clone.GetPublicKey (), "GetPublicKey");
		Assert.AreEqual (an.GetPublicKeyToken (), clone.GetPublicKeyToken (), "GetPublicKeyToken");
		Assert.AreEqual (an.ToString (), clone.ToString (), "ToString");
	}
开发者ID:wamiq,项目名称:debian-mono,代码行数:22,代码来源:AssemblyNameTest.cs

示例14: Matches

 bool Matches(AssemblyName a, AssemblyName b)
 {
     return a.ToString() == b.ToString();
 }
开发者ID:LenFon,项目名称:Bifrost,代码行数:4,代码来源:AssemblyProvider.cs

示例15: ProcessAssemblyName

        private void ProcessAssemblyName(AssemblyName assemblyName)
        {
            WriteVerbose("DisplayName: " + assemblyName.ToString());

            if (_version != null)
            {
                if (_version != assemblyName.Version)
                {
                    WriteVerbose(String.Format("Version: {0} != {1}", _version, assemblyName.Version));
                    return;
                }
            }

            if (Import.IsPresent)
            {
                WriteVerbose("Importing " + assemblyName);

                // import the assembly
                WriteObject(Assembly.Load(assemblyName));
            }
            else
            {
                // pass-thru AssemblyName object
                WriteObject(assemblyName);
            }
        }
开发者ID:razaraz,项目名称:Pscx,代码行数:26,代码来源:ResolveAssemblyCommand.cs


注:本文中的System.Reflection.AssemblyName.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。