Need fully qualified type name

≡放荡痞女 提交于 2019-12-08 16:29:37

问题


I need to resolve an assembly and type at runtime and I need to find the fully qualified type name. For some reason I cannot get it right, as I keep get an exception saying it cannot find the type specified.

The app.config file, in which the assembly to look for is defined, looks like this:

<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>

The assembly is called: Driver.Data.Module Namespace in assembly is: Driver.Data.Module and type name is: DriverDataModule, and this is also the name of the .cs file.

I cannot seem to find how to specify the name correctly in the xml file. Can somebody help me with the fully qualified type name?

This is for a Composite WPF application.

Thanx!


回答1:


Try Driver.Data.Module.DriverDataModule, Driver.Data.Module.

You can also find the full assembly-qualified name of your type by instantiating an object of that type and examining the AssemblyQualifiedName property of its Type:

DriverDataModule module = new DriverDataModule();
string fullyQualifiedName = module.GetType().AssemblyQualifiedName;



回答2:


What error do you get? If you're having a hard time getting a full error message out of the app, and you think your app is having problems loading the assembly itself, you can use the fuslogvw tool to log full details to disk.

It's worth also opening the assembly in Reflector to double-check the assembly's full name (displayed on the bottom-left of the window when you open Reflector), and to check that the type is in fact defined in the namespace you think it is.



来源:https://stackoverflow.com/questions/2404061/need-fully-qualified-type-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!