if the custom control is in App_Code folder, than what will be it's assembly name in the <%@register

U

Umut Tezduyar

I know that, in asp.net 2.0, the assembly for the web site is splitted into
pieces and each time you build it, it generates a random name for assembly.

My question is, if i create a custom web control under the App_Code folder,
how can i add a register tag on a page.

<%@ Register TagPrefix="ABC" Namespace="ABC.Foo" Assembly="???????????????"
%>

My other question is "Since i don't know the name of the assembly of the
asp.net 2.0 web site, how can dynamically load that assembly using the
Assembly.CreateFromFile () method??

Thank you
 
B

Brock Allen

Use "__code":

<%@ Register TagPrefix="ABC" Namespace="ABC.Foo" Assembly="__code" %>
 
U

Umut Tezduyar

Thank you so much.

How can i load that assembly on the fly using
Assembly.LoadFrom ()
 
B

Brock Allen

Why would you need to manually load the assembly? Just call "new" on the
control/class defined in the App_Code directory.
 
U

Umut Tezduyar

I have a custom control on a seperate assembly. I give a reference to that
custom control from web site. This web control loads "custom controls" that
are under the app_code folder. Maybe i am not clear but, i definetely need
to find a way to load them.

This is the inside of the load method. This was valid at 1.1. It is no more
valid at asp.net 2.0

// The assembly will be searched in the bin folder of the application

string path = AppDomain.CurrentDomain.BaseDirectory + "bin" + "/" +
cstModule.Assembly + ".dll";

// Load assembly

ass = Assembly.LoadFrom(path);

// Load control from assembly

control = (System.Web.UI.Control)ass.CreateInstance(cstModule.TypeName);
 
U

Umut Tezduyar

By the way, it gives an error for _code

<%@ Register Assembly="_code" Namespace="A" TagPrefix="abc" %>

Error 3 Could not load file or assembly '_code' or one of its dependencies.
The system cannot find the file specified. C:\Documents and
Settings\utezduyar\My Documents\Visual Studio
2005\WebSites\WebFrameworkTestSite\Default.aspx 2
 
U

Umut Tezduyar

<%@ Register Assembly="App_Code" Namespace="A" TagPrefix="abc" %>

This is working perfectly.
 
U

Umut Tezduyar

I found the solution for this.

System.Reflection.Assembly.Load (string assemblyName) solves all of my
problems.

System.Reflection.Assembly.Load ("App_Code") works perfectly.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top