dll からパブリック ユーザー定義関数を検索したい場合publickeytoken == null
OpenFileDialog obj = new OpenFileDialog();
if (obj.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Assembly ass = Assembly.LoadFrom(obj.FileName);
// Here its getting Exception because Publickeytoken == null;
Assembly a = Assembly.LoadWithPartialName(ass.FullName);
Type[] types = a.GetTypes();
foreach (Type type in types)
{
if (!type.IsPublic)
{
continue;
}
MemberInfo[] members = type.GetMembers(BindingFlags.Public
| BindingFlags.Instance
| BindingFlags.InvokeMethod);
foreach (MemberInfo member in members)
{
Console.WriteLine(type.Name + "." + member.Name);
}
}
}
これを解決する方法
publictokenkey を検索するためにこれを試しても、0 バイトが返されます
byte[] b = Assembly.GetExecutingAssembly().GetName().GetPublicKeyToken();