Instantiate TableAdapter at Runtime

M

Mark Olbert

I have a TableAdapter declared in my website's App_Code directory (I'm using the declarative approach to design it).

If, in a web page from the site, I try to instantiate an instance of the TableAdapter dynamically:

protected void Page_Load(object sender, EventArgs e)
{
// check that we can find the Type of the TableAdapter
Type junk = typeof(page_infoTableAdapters.bd_contentTableAdapter);

// now try to create the Type
junk = Type.GetType("page_infoTableAdapters.bd_contentTableAdapter");

//!!!!! junk is null !!!!!!!!!!
// construction logic left out of example

I can't create the Type.

I've run into this before, and it normally means I need to fully-qualify the Type name with the name of the defining assembly. Only
the defining Assembly in this case is dynamically-created by Visual Studio...so what do I do?

- Mark
 
M

Mark Olbert

For the benefit of anyone else running into the same problem...

A solution is to append App_Code to the Type name. That doesn't make it fully-qualified, because App_Code isn't the name of an
assembly. But, for whatever reason, it lets the Type resolver find/create the Type:

junk = Type.GetType("page_infoTableAdapters.bd_contentTableAdapter, App_Code");

- Mark
 

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,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top