How can I retrieve an assembly's qualified type name?

后端 未结 5 2068
孤独总比滥情好
孤独总比滥情好 2021-01-06 09:56

How can I generate a assembly qualified type name?

For an example, when configuring a membership provider, I would have to provide a assembly qualified type name for

5条回答
  •  清酒与你
    2021-01-06 10:20

    AFAIK the Fully qualified type name consists in the Class name and the assembly signature. I don't think that you can generate it...

    The type is the namespace.

    The version you can set it in the AssemblyInfo.cs (remove the * for keep it the same)

    The public key token you set it in the Project properties.

    That's from what i remember

    other way to obtain the assembly qualified name could be:

    class Program
        {
            static void Main(string[] args)
            {
                string assemblyPath = args[0];
                Assembly loadedAssembly = Assembly.LoadFrom(assemblyPath);
                Module[] modules = loadedAssembly.GetModules();
                Console.WriteLine("Assembly: " + loadedAssembly.GetType().Name);
                foreach (Module module in modules)
                {
                    Console.WriteLine("Module: {0}\nFullyQualifiedName: {1}", module.Name, module.FullyQualifiedName);
                    Type[] types = module.GetTypes();
                    foreach (Type type in types)
                    {
                    Console.WriteLine("Type: {0}\n FullName: {1}", type.Name, type.FullName);    
                    }
                }
                Console.ReadLine();
            }
        }
    

提交回复
热议问题