bin folder?

G

Guest

Microsoft documentation states:
Bin Folder
You can store compiled assemblies in the Bin folder, and other code anywhere
in the Web application (such as code for pages) automatically references it.
A typical example is that you have the compiled code for a custom class. You
can copy the compiled assembly to the Bin folder of your Web application and
the class is then available to all pages.

Assemblies in the Bin folder do not need to be registered. The presence of a
..dll file in the Bin folder is sufficient for ASP.NET to recognize it. If you
change the .dll and write a new version of it to the Bin folder, ASP.NET
detects the update and uses the new version of the .dll for new page requests
from then on.

So my question is: Why in the @register directive do you need the assembly
value to register a tag? Shouldn't the assembly just be available? If not,
what does the microsoft documentation mean when it says dlls here are
available to the entire site?

-Ben
 
K

Karl Seguin [MVP]

In order to load a type efficiently, the assembly name must be available.

The only way to load a type from the class's full name is to loop through
all loaded assemblies in the GAC and check each one. This would mean
System.dll, System.Web.dll and probably 15 more assemblies would need to be
checked. Certainly not the best way to go about.

Also, having the assembly name greatly increases the maintainability and
readability of your code.

Karl
 
S

Steven Cheng[MSFT]

Hi Ben,

As Karl has mentioned, though the ASP.NET runtime can always loop all the
assemblies in the private bin dir to locate a certain type, use explicit
assembly name can make the process more effecient. In addition, ASP.NET
will utilize dynamic compilation (and it is the main compilation model in
ASP.NET 2.0), then there may exists dynamic compiled assembly which may
reference other assemblies (in private bin) dir, explicitly provide the
assembly name can also help the compilation process simplified
(conveniently add the reference to dependent assemblies).

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Steven,

Thaks for the response. Do I understand correctly that the addition of the
"assembly" keyword is optional but enhances performance? In my testing,
removing the keyword broke the assembly reference. And what about for types
that are placed in the app_code folder? I was under the impression that those
are compiled into the main website assembly and thus the keyword can be
omitted. Also, could you elaborate on how this ties to dynamic compilation?
I'm not sure I follow.

Thanks again Steven...

-Ben
 
S

Steven Cheng[MSFT]

Thanks for your response Ben,

Though it is used for improve performance, we can not ignore it as we like,
must followup the rule mentioned in MSDN. Actually the @Regiser directive
can be used for register both ascx usercontrol and webserver control. In
two cases , the requirement are different.

#@ Register
http://msdn2.microsoft.com/en-us/library/c76dd5k1(VS.80).aspx

And the "assembly", "namespace" attribute are always required for webserver
control, if the control is defined in classes within "App_Code" folder,
the "assembly" attribute's value can be set as "App_Code" or "__code", e.g:

<%@ Register TagPrefix="ac" Namespace="test" Assembly="__code" %>

And for 1.1 ASP.NET appliation, the VS IDE will compile codebehind and
other source classes into a main assembly. Hoewver, for 2.0, this is not
the case, 2.0 ASP.NET application utilize dynamic compilation, page classes
and other source classes in App_Code folder may be compiled into different
dynamic assemblies. And for page classes and classes in App_code, the
runtime know how to locate them in those dynamic compiled assemblies.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top