DOT NET 4.0 – Directives for Web Forms Pages – @ Assembly Directives

Links an assembly to the current page during compilation, making all the assembly’s classes and interfaces available for use on the page.

<%@ Assembly Name="assemblyname" %>
<%@ Assembly Src="pathname" %>

Attributes

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 You cannot include a Name and Src attribute in the same @ Assembly directive. If you want to use both, you must include more than one directive on the page.

Remarks

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.

Example

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" %>

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s