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

  • Thread starter Thread starter Umut Tezduyar
  • Start date Start date
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
 
Thank you so much.

How can i load that assembly on the fly using
Assembly.LoadFrom ()
 
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);
 
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
 
<%@ Register Assembly="App_Code" Namespace="A" TagPrefix="abc" %>

This is working perfectly.
 
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

Back
Top