How do you extract an assembly full name from the assembly qualified name of a type?

Here: public string AssemblyName(string assemblyQualifiedName) { Type type = Type. GetType(assemblyQualifiedName, false); if(type == null) { return Parse(assemblyQualifiedName); } return type.Assembly. Name; } Edit: Wait.

You don't have the assembly? Sorry to be the bearer of bad news, but then you need to parse.

Unfortunately my application won't have access to the actual type for me to call GetType at the time I have to perform the parsing... – Paul Killick Dec 2 '09 at 5:32 @Paul K: Yeah, if you don't have the assembly then you need to parse the string. Reflection etc. Won't help you here as the CLR can't find the metadata for the type to perform reflection over. I try to avoid questioning motives, but what's wrong with parsing here?

– Jason Dec 2 '09 at 5:35 @Jason, thx for your input... nothing wrong with parsing if that's what I have to resort to, but the FQN can get involved (MSDN "Specifying Fully Qualified Type Names"), and I just though a publicly exposed framework solution might exist since it must have to parse these things internally anyway... – Paul Killick Dec 2 '09 at 6:02.

If you want to use GetType you'll need to load the assembly to the current domain. You can learn how to do it here. Although it seems like a lot of work just to avoid trivial parsing...

An overload to Type. GetType accepts an function that can be used to resolve the AssemblyName to an assembly. Returning null would normally throw an exception since the type cannot be resolved, but this can be suppressed by passing false to the throwOnError parameter.

The function used to resolve can also set a string variable in the outer scope that the original code will return. Using System; using System. Diagnostics; using System.

Reflection; namespace ConsoleApp { public static class Program { public static void Main() { var assemblyName = GetAssemblyName("MyNamespace. MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); Debug. Assert(assemblyName == "MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); } public static String GetAssemblyName(String typeName) { String assemblyName = null; Func assemblyResolver = name => { assemblyName = name.

FullName; return null; }; var type = Type. GetType(typeName, assemblyResolver, null, false); if (type! = null) return type.

AssemblyQualifiedName; return assemblyName; } } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions