我需要解析一个程序集并在运行时键入,我需要找到完全限定的类型名称.出于某种原因,我无法做到正确,因为我一直得到一个例外,说它无法找到指定的类型.
app.config文件,其中定义要查找的程序集,如下所示:
<configSections>
<section name="modules" type="Microsoft.Practices.Composite.Modularity.ModulesConfigurationSection, Microsoft.Practices.Composite"/>
</configSections>
<modules>
<module assemblyFile="G:\Data\Visual Studio 2008\Projects\Race Management System.Shell\ConfigurationModularity\bin\Debug\Modules\Driver.Data.Module.dll" moduleType="Driver.Data.Module.DriverDataModule, DriverDataModule" moduleName="Driver.Data.Module.DriverDataModule"></module>
</modules>
Run Code Online (Sandbox Code Playgroud)
调用 程序集:Driver.Data.Module程序集中的命名空间是:Driver.Data.Module ,类型名称是:DriverDataModule,这也是.cs文件的名称.
我似乎无法找到如何在xml文件中正确指定名称.有人可以用完全限定的类型名称来帮助我吗?
这适用于复合WPF应用程序.
感谢名单!
给出以下代码:
var n1 = new AssemblyName ("TestDll, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
var n2 = new AssemblyName ("TestDll, Version=2.0.0.2001, Culture=en-US, PublicKeyToken=ab7a5c561934e089");
Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n1, n2));
Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n2, n1));
Run Code Online (Sandbox Code Playgroud)
为什么这两个检查都打印“True”?我本以为 AssemblyName.ReferenceMatchesDefinition 应该考虑程序集名称的版本、区域性和公钥标记属性的差异,不是吗?
如果没有,ReferenceMatchesDefinition 能做什么而简单名称的比较却不能做什么?
我得到一个程序集的名称如下:
String fullName = Assembly.GetAssembly(typeof(CP.Proj.ILogger)).FullName;
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
CP.Proj,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null
有没有办法只获得程序集名称"CP.Proj",没有版本和其他信息?
假设我有项目A和项目B。在相同的解决方案中有它们,并且A引用B并将B用作一种从属进程。我不想对B的程序集名称进行硬编码,但我想知道如何在项目A中查询程序集名称,以便可以执行项目B的程序集。