ASP.NET Syntax ASP.NET Page Syntax Page Directives
Links an assembly to the current page during compilation, making all of the assembly’s classes and interfaces available for use on the page.
<%@ Assembly Name = "assemblyname" %>
<%@ Assembly src="pathname" %>
Name |
A string that represents the name of the assembly to link to the page.
NOTE: The assembly name does not include a file name extension. |
Src |
The path to a source file to dynamically compile and link against.
NOTE: The Name and Src attributes in the same @ Assembly directive. If you want to use both, you must include more than one directive on the page. |
The compiler references the assembly at compile time, allowing early binding. Once compilation of the requested page is complete, the assembly is loaded into the application domain, allowing late binding.
Assemblies that reside in your Web application’s \bin directory are automatically linked to pages within that application. Such assemblies do not require the @ Assembly directive. You can disable this functionality by removing the following line from the <assembly
> section of your application’s Web.config file:
<add assembly = "*" />
NOTE: You cannot include the path to an assembly in an @ Assembly directive.
As an alternative to using the <%@ Assembly %
> directive, you can use the Web.config file to link assemblies across an entire application. For more information about the Web.config file and configuring your application, see ASP.NET Configuration.
The following code fragment uses two <%@ Assembly %
> directives, the first to link to a user-defined assembly, myAssembly
, the second to link to a Visual Basic.NET source file, mySource.vb
:
<%@ Assembly Name = "myAssembly" %>
<%@ Assembly src = "mySource.vb" %>
Page Directives