473,378 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Type.GetType() ASP.NET Beta 2

Hi

I have a class in the App_Code location of my web project.

example:
namespace Company.AppName.Objects {
public class ObjectA {
public ObjectA(){
}

public void DoSomething() {
}
}
}

In a web page I want to dynamically get the type of this class like so:

Type t = Type.GetType("Company.AppName.Objects.ObjectA");

However this code will return a null null object, due to the compilation
model of ASP.NET 2, it basically can't find the dll to load the type.
ASP.NET 1.x didn't have this problem because the code-behind was represented
in a single dll.

Apart from say putting ObjectA into it's own project thus dll, does anyone
know of a way around this?

Craig
Nov 19 '05 #1
4 2656
This wouldn't work in any environment since you don't have the assembly specified
in GetType. GetType expects a parameter like "Namespace.Class, Assembly".

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a class in the App_Code location of my web project.

example:
namespace Company.AppName.Objects {
public class ObjectA {
public ObjectA(){
}
public void DoSomething() {
}
}
}
In a web page I want to dynamically get the type of this class like
so:

Type t = Type.GetType("Company.AppName.Objects.ObjectA");

However this code will return a null null object, due to the
compilation model of ASP.NET 2, it basically can't find the dll to
load the type. ASP.NET 1.x didn't have this problem because the
code-behind was represented in a single dll.

Apart from say putting ObjectA into it's own project thus dll, does
anyone know of a way around this?

Craig


Nov 19 '05 #2
Hi Brock

Do you have any suggestions on how I can make this functionality work for me
under ASP.NET v2?

Craig

"Brock Allen" wrote:
This wouldn't work in any environment since you don't have the assembly specified
in GetType. GetType expects a parameter like "Namespace.Class, Assembly".

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a class in the App_Code location of my web project.

example:
namespace Company.AppName.Objects {
public class ObjectA {
public ObjectA(){
}
public void DoSomething() {
}
}
}
In a web page I want to dynamically get the type of this class like
so:

Type t = Type.GetType("Company.AppName.Objects.ObjectA");

However this code will return a null null object, due to the
compilation model of ASP.NET 2, it basically can't find the dll to
load the type. ASP.NET 1.x didn't have this problem because the
code-behind was represented in a single dll.

Apart from say putting ObjectA into it's own project thus dll, does
anyone know of a way around this?

Craig


Nov 19 '05 #3
Well, I don't know what you're tying to do exactly. My first thought when
I saw your original post was "Why don't you just use typeof(Company.AppName.Objects.ObjectA)"

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi Brock

Do you have any suggestions on how I can make this functionality work
for me under ASP.NET v2?

Craig

"Brock Allen" wrote:
This wouldn't work in any environment since you don't have the
assembly specified in GetType. GetType expects a parameter like
"Namespace.Class, Assembly".

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a class in the App_Code location of my web project.

example:
namespace Company.AppName.Objects {
public class ObjectA {
public ObjectA(){
}
public void DoSomething() {
}
}
}
In a web page I want to dynamically get the type of this class like
so:
Type t = Type.GetType("Company.AppName.Objects.ObjectA");

However this code will return a null null object, due to the
compilation model of ASP.NET 2, it basically can't find the dll to
load the type. ASP.NET 1.x didn't have this problem because the
code-behind was represented in a single dll.

Apart from say putting ObjectA into it's own project thus dll, does
anyone know of a way around this?

Craig


Nov 19 '05 #4
Hi Brock

Yeah typeof would certainly do the trick, the problem is my page has a
drop-down control with ListItems as:
<option value="Company.Project.Objects.ObjectA">ObjectA</option>

From the SelectedValue property I wish to create the type, as I mentioned,
ASP.NET 2 compilation model means that ObjectA won't be compiled until
invoked (assuming this is correct).

After some digging around, I found the aspnet_compiler.exe. This allows for
pre-compiled code of the App_code folder. So now I can use
Type t = Type.GetType("Company.Project.Objects.ObjectA");

Which returns the correct type. I'm yet to find holes in this approach
which is a good sign.

Craig
"Brock Allen" wrote:
Well, I don't know what you're tying to do exactly. My first thought when
I saw your original post was "Why don't you just use typeof(Company.AppName.Objects.ObjectA)"

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi Brock

Do you have any suggestions on how I can make this functionality work
for me under ASP.NET v2?

Craig

"Brock Allen" wrote:
This wouldn't work in any environment since you don't have the
assembly specified in GetType. GetType expects a parameter like
"Namespace.Class, Assembly".

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

I have a class in the App_Code location of my web project.

example:
namespace Company.AppName.Objects {
public class ObjectA {
public ObjectA(){
}
public void DoSomething() {
}
}
}
In a web page I want to dynamically get the type of this class like
so:
Type t = Type.GetType("Company.AppName.Objects.ObjectA");

However this code will return a null null object, due to the
compilation model of ASP.NET 2, it basically can't find the dll to
load the type. ASP.NET 1.x didn't have this problem because the
code-behind was represented in a single dll.

Apart from say putting ObjectA into it's own project thus dll, does
anyone know of a way around this?

Craig


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Bower | last post by:
Reposted from aspnet.buildingcontrols: Ok, I've got a bunch of derived controls that all have a property Rights of type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so that I...
2
by: Andrew Feldman | last post by:
Is someone from MS listening? Every thread I've seen on this topic goes dead. Even the MVP's don't seem to have an answer. My problem: I'm working with ASP.NET 2.0 Beta 1. I have all web...
3
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. ...
2
by: S. Justin Gengo | last post by:
Hi, I've created a component that allows me to store database information for various types of databases my company uses. It uses a collection for each type of database. Everything is working...
6
by: Charles Law | last post by:
I want to do something like this: obj = CType(value, Value.Type) Well, not exactly, but I think that captures the essence. I realise it won't work as I have written it, and it looks a bit like...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
7
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}"...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.