473,396 Members | 1,940 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,396 software developers and data experts.

Creating instances of *unknown types* declared in my App_Code and not in a DLL

Hi all,

I'm trying to write a plugin system for a website whereby a user can drop a class in the App_Code directory and then pass the class name on the query string of the aspx file and the ASPX will create an instance of this class.

I've been pratting about with various things but this is my first attempt/hack at reflection.

What i have so far in my Aspx codebeheind is
Expand|Select|Wrap|Line Numbers
  1. namespace MyNS{
  2.     public partial class _Default :System.Web.UI.Page {
  3.         string _class = Request.QueryString["class"];
  4.  
  5.         object instance = Activator.CreateInstance(this.GetType().AssemblyQualifiedName, 
    this.GetType().Assembly+"." + _class);
        }
  6. }
  7.  
and in my class file
Expand|Select|Wrap|Line Numbers
  1. namespace MyNS {
  2.     public class TestClass {
  3.         public TestClass() {
  4.             //
  5.             // TODO: Add constructor logic here
  6.             //
  7.         }
  8.  
  9.         public string Get() {
  10.             return this.ToString();
  11.         }
  12.     }
  13. }
  14.  

I thought by wrapping both bits of code in the same namespace i would be able to make use of
this.GetType().AssemblyQualifiedName
from the aspx but i get this error
Expand|Select|Wrap|Line Numbers
  1. Could not load file or assembly 'ASP.Default_aspx\, App_Web_jbgiblwi\, Version\=0.0.0.0\, Culture\=neutral\, PublicKeyToken\=null' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
  2.  
I've seen a few articles that show you how to write a plugin architecture which relies on dll's and Activator.CreateInstanceFrom but i want the users to be able to upload .CS source files and achive the same thing.

Thanks for any help.

Greg
Sep 5 '07 #1
3 1635
Plater
7,872 Expert 4TB
Is your website running as partially compiled (default when you publish) ?
Sep 5 '07 #2
Is your website running as partially compiled (default when you publish) ?

yes, the website will be partially compiled
Sep 5 '07 #3
Plater
7,872 Expert 4TB
Then the CS file I think will need to be linked before you do the partial compile, as .CS files are not transfered over on a publish of a partially compiled website
Sep 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to...
4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
7
by: nog | last post by:
What's the best approach to creating many objects of a class? I have in mind using something analogous to a table to hold the data - which is in a form similar to (char name, char address, date...
6
by: Joanna Carter \(TeamB\) | last post by:
I want to be able to use a generic type, bind its generic parameters to specific type(s) and then hold newly created instances in a list of generic ypes. Sort of like this : class Agent<T> {...
8
by: Simon Edwards | last post by:
Something thats been bugging me for a while... how do you create a namespace that has many children (namespaces) I.e system.io.blah.blah Iv'e done it by creating a class which contains...
4
by: Don | last post by:
When creating a new region for a control via a GraphicsPath object, it appears the entire rightmost column of pixels and bottom most row of pixels are not included in the region. I will try to...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
3
by: Peter Morris | last post by:
Hi all Let's say I am creating a model to represent classes and properties. In addition to this I need instances of classes and values for those properties. KEY: (AssociationEndName)
33
by: Adam Chapman | last post by:
Hi, Im trying to migrate from programming in Matlab over to C. Im trying to make a simple function to multiply one matrix by the other. I've realised that C can't determine the size of a 2d...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.