I created an empty web form application that run under .Net Framework 4.7.2 and created a webform and a class named MyClass:
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string GetText()
{
return "Message of Web Form 1";
}
}
}
and:
namespace WebApplication1
{
public class MyClass
{
public string GetText()
{
return "Message from MyClass";
}
}
}
and I publish it using "Merge all assemblies in one assembly" option:

Then I want to get type and then create instance of WebForm1 and MyClass.
I wrote this code in a console application that run under .Net 5:
Assembly asm = Assembly.LoadFrom(@"C:\Pub\bin\WebApplication1.dll");
Type tMyClass = asm.GetType("WebApplication1.MyClass");
Type t = asm.GetType("WebApplication1.WebForm1"); <----Error
After the code has run, tMyClass has the correct type:
]
but when I try to get the type of WebForm1, I get an error:
System.TypeLoadException: 'Could not load type 'System.Web.UI.Page' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.'
How can I get type of WebForm1 and create an instance of it?
