1

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

Ashish Sharma
  • 357
  • 2
  • 5
  • 16

1 Answers1

0

Perhaps giving the assembly qualified name, ie:

MyNameSpace.ITestInterface, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
armen.shimoon
  • 6,303
  • 24
  • 32
  • Type.GetType only looks in the currently executing assembly and in mscorlib when you don't specify an assembly name (http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx) – fsimonazzi Sep 15 '12 at 01:51