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("C ompany.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 4 2675
This wouldn't work in any environment since you don't have the assembly specified
in GetType. GetType expects a parameter like "Namespace.Clas s, 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("C ompany.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
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.Clas s, 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("C ompany.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
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.Clas s, 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("C ompany.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
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">Objec tA</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("C ompany.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.Clas s, 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("C ompany.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 can use comma separated values in design-time. The TypeConverter
works great in design-time. It converts to and from just fine... However,
when I try to load any page in the site now I get the following error
(Following the error is code for the...
|
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 application
instance-specific code factored into the /code directory of my web
project. I have custom EventArgs/Handler's for my current web app
instance that I would like to create and use dynamically via
reflection, from a web control in the same...
|
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'.
here is the code that I used to create a table and then add columns to it
later, later I populate the rows in the table.
|
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 perfectly except when the component
is deleted from the page. Here are the details.
I add the component to the page from the toolbox and then add items using
the collection editor. I can delete those items from the collection using
the collection...
|
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 a nebulous statement, but
I am looking for a generic way to convert a variable of unknown type to its
actual type.
Perhaps a better example would be
| |
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 can get this using:
dim b as string
b = DirectCast(myarraylist(0),myclass).myproperty
However, I want to use an object to define the type "MyClass" like:
dim C as type = type.GetType(myarraylist(0))
|
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)
|
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}"
As far as I know yet -- hence this question -- there is no 'one solution
fits all', but instead there are several parts that have to be put together
to check.
What I have so far is, and would like as much feedback as possible to ensure
I've...
|
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 down the line...
What happens when my code is run on a station that only has framework 3.0 or
4.0, and this assembly, with version number defined for 2.0.0.0 , isn't
available. ...breaks?
Second question:
Does an assembly's PublicKeyToken change...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |