I am modifying T4 controller template of visual studio 2013. I need to find the type of a model class (e.g. Hospitalization model). Please also note that I have one project in the solution. Hospitalization
class is defined in namespace WebApplication2.Models
what I did:
<#@ assembly name="C:\Users\noornayeem\Documents\Visual Studio 2013\Projects\WebApplication2\WebApplication2\bin\WebApplication2.dll" #>
...
<#@ import namespace="WebApplication2.Models" #>
....
<#+
void foo()
{
string str ="WebApplication2.Models.Hospitalization, WebApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
Type typeModel = Type.GetType(str);
//typeModel is always null here
}
#>
In the foo()
function, I tried with typeof(WebApplication2.Models.Hospitalization)
. This works. However, I want to get the type by using string name. Any hep will be appreciated.
I tried this. but it is not working.