I have written a VirtualPathProvider to change how aspx pages are loaded into my ASP.Net application. As part of this process I have removed Code-Behind files and I am simpl
Your page must use the full specified class location - i.e. Inherits="MyNamespace.MyClass, MyAssembly"
.
Then loading the assembly into the appDomain is not going to help AppDomain resolve it. It doesn't walk the dynamically loaded assemblies. So you must subscribe for the AppDomain.ResolveAssembly event.
private Assembly myDynamicAssembly = null;
protected void Application_Start( object sender, EventArgs e )
{
myDynamicAssembly = Assembly.LoadFrom( Server.MapPath( "MyLocation/MyAssembly.dll" ) );
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler( CurrentDomain_AssemblyResolve );
}
Assembly CurrentDomain_AssemblyResolve( object sender, ResolveEventArgs args )
{
if ( args.Name == "MyAssembly" )
{
return myDynamicAssembly;
}
return null;
}
And you're done. Now the runtime knows how to resolve classes from this dynamically loaded assembly.
Possible causes:
If you refer to any code behind module in .aspx pages or Global.asax page and the web application has'nt been built then you get this error. Just build the application again and make sure that the type Namespace.PageClass is available in one of the web application assemblies.
Use @Assembly directive to link the assembly to the aspx page at compile time.
@ Assembly Name="assemblyname" Src="pathname" makes all the assembly's classes and interfaces available for use.
2.Another reason for such an error could be a wrong version of ASP.NET configured in IIS. To select the correct version of ASP.NET in IIS
Go to Start Menu, click on Run (alternatively use Win Key + R )
Type INetMgr and press enter to open Internet Information Services Application
Expand the tree node displaying local computer name and navigate to Web Sites-->Default Web Site
Right click on Default Web Site node and select the popup menu option Properties
5.Navigate to ASP.NET tab in the properties page and set the correct/latest version.