Domanda

I am using PRISM (recently started).

How do I dynamically resolve the interface type defined as the string and pass it to Container.Resolve?

For example, I have an interface called MyNamespace.ITestInterface. I also have a string which holds the name of this interface now when I try to execute the following program it gives me null:

namespace MyNamespace
{
     public interface ITestInterface
     {
          void DoSomething();
     }
}

main()
{
     Type interfaceType = Type.GetType("MyNamespace.ITestInterface"); //This line gives me null
}

The interface type is set in the configuration file to identify which interface is to be used. So, this will always be in string.

BTW, I am already loading the relevant assembly in which interface is defined.

Any help would be greatly appreciated.

Thanks in advance, Ashish Sharma

È stato utile?

Soluzione

Perhaps giving the assembly qualified name, ie:

MyNameSpace.ITestInterface, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top