Windows应用程序参考 [英] Windows Application Reference

查看:77
本文介绍了Windows应用程序参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

推荐答案



对于运行时,您需要使用反射.请点击链接
反射(C#编程指南)

问候
AR
Hi,

for Runtime, You need to use reflection. Please go through with the link
Reflection (C# Programming Guide)

Regards
AR


您好,

System.Reflection是您的朋友在这里.这是在运行时获取引用程序集的方式.
Hi there,

System.Reflection is your friend here. This is how you get the referenced assemblies in run-time.
StringBuilder builder = new StringBuilder();

Assembly currentAssembly = Assembly.GetExecutingAssembly();
AssemblyName[] referencedAssemblies = currentAssembly.GetReferencedAssemblies();
foreach (AssemblyName assembly in referencedAssemblies)
{
    builder.AppendLine(assembly.FullName);
}

MessageBox.Show(builder.ToString());


这里要注意的一件事是,该列表 可能与VS的解决方案资源管理器中的引用列表不完全相同 .造成这种情况的原因有很多,但是主要原因是,即使您将引用添加到项目中,也不会在您的代码中使用它们.这些程序集将不会在运行时被引用或加载,因此不会列出.

希望对您有所帮助:)问候


One thing to note here is that, this list may not be exactly equal to the the list of references in the Solution Explorer of VS. There are numerous reasons for this, but the main reason is that, even though you add references to a project, they won''t be used in your code. Those assemblies will not be referenced or loaded in run time, hence they won''t be listed.

Hope this helps :) Regards


这里是您的另一个例子

Here is another example for you

Assembly a = Assembly.LoadFrom("c:\\COPYPROT.exe");
           Type[] types = a.GetTypes();
           foreach (Type typ in types)
           {
               object obj;
               if (typ.Name.ToUpper() == "READENCRYPTION")
               {
                   obj = Activator.CreateInstance(typ);
                   MethodInfo mi = typ.GetMethod("EncryptFile");
                   mi.Invoke(obj, new object[] { (string)"1", (string)"2", (string)"0408" });
               }
           }



这里 EncryptFile 方法具有3个参数



Here EncryptFile method have 3 parameters


这篇关于Windows应用程序参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆