.NET Plugin Architecture Without Using Reflection Or Static Constructors?
Nov 11, 2010
I have an ASP.NET HttpModule that is distributed as a DLL. I badly need a plugin architecture so I can isolate some heavyweight, rarely used features into external .dlls, and speed up/slim up the core functionality.I've experimented with (1) reflection and (2) static constructors.It seems GoDaddy and a few other web hosts prohibit use of Reflection, making #1 useless..NET 4.0 now calls static constructors lazily, eliminating #2.
How can I have a generic plugin registration system that doesn't require C# or VB code to register the plugins? Even a web.config plugin registration list would be fine, but I don't know how to do that without using reflection.
Update: I need this to work in .NET 2.0 as well as higher versions
View 1 Replies
Similar Messages:
Oct 1, 2010
I am trying to develop a plugin architecture in .Net. The application will be a .Net application. There will be directories which holds the plug-ins. Each directory will represent a plugin. Each plugin directory will also contain all the dependency dlls as well. The plugins need to be stored in separate AppDomain as the plugins may use the same assemblies, but different versions. As it iterates through the foreach loop in Init(), I get a System.IO.FileNotFoundException : Could not load file or assembly '[Assembly Name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.in _apDomain.Load() for assemblies that are not in the main project.
readonly private AppDomain _appDomain;
internal ItemModuleAppDomain()
{
AppDomainSetup info = AppDomain.CurrentDomain.SetupInformation;
_appDomain = AppDomain.CreateDomain("ChildDomain");
}
public void Init(string dllDir)
{
string[] dlls = Directory.GetFiles(dllDir, "*.dll", SearchOption.TopDirectoryOnly);
foreach(string dll in dlls)
{
_appDomain.Load(AssemblyName.GetAssemblyName(dll));
}
View 1 Replies
Aug 6, 2010
Edit: I would like to keep the infrastructure as is, so while the framework ideas are appreciated, please keep your suggestions centered on the context I have provided.
Background
I'm building a web-based application that dynamically loads plugins. Each plugin comes with a manifest file that contains its dll location, namespace, and type.
Right now I'm using System.Reflection.Assembly.LoadFile to load up the dlls based off the locations provided in the manifest files. Then I load the types and so on.
As an Aside:
I may wind up changing to System.Reflection.Assembly.LoadFrom since I'll eventually be loading files from outside the bin directory. But if their is a better way (Assembly.Load or something), feel free to add that in as well
Problem
The problem is that Multiple plugins can potentially run off the same dll. So I wind up executing System.Reflection.Assembly.LoadFile("Identical.dll") multiple times.
I have the idea to check if my assembly has already been loaded by iterating through AppDomain.CurrentDomain.GetAssemblies(), but I don't know if that will help with performance (or if it will work period, I haven't tried it).
Also, I can't keep a list of loaded assemblies due to the project's design constraints (though you may argue that it's a poor design: I can't change it, even if I wanted to OR agreed with you... so please don't press the issue.
Ultimately my goals are:
Don't ever re-load the same assembly twice. Performance is key.
View 3 Replies
Jan 5, 2010
I have designed an application and am wondering if this is the best architecture to use and whether there is any danger.
In namespace Membership I have a public class, MembershipManager, which inherits from webservice
public class MembershipManager() : System.Web.Services.Webservice
The single public web method of this class often needs to read and write to a database.
[WebMethod()] public string DoMembershipWork(...various parameters...)
The database work is done by implementing, in the same namespace,an internal class
internal class MembershipDataAccess
which has a series of internal static methods for data access e.g.
internal static bool UpdateMembership(MembershipManager m)
The MembershipManager class accesses the data access class by calling the appropriate method with itself as a parameter e.g.
MembershipDataAccess.UpdateMembership(this);
Is this a good idea. This application will be processing many transactions simultaneously. Is there a danger of not being thread safe. Note also that sometimes the MembershipDataAccess class will return datasets to the MembershipManager class.
View 2 Replies
Jun 28, 2010
I have searched deference between Static and Singleton Patten on google but did not get it clearly.
View 12 Replies
Apr 30, 2010
If for example you have a function Public shared function GetStockByID(StockID as Guid) as Stock Is that function common to all current users of your application? Or is the shared function only specific to the current user and shared in the context of ONLY that current user? So more specifically my question is this, besides database concurrency issues such as table locking do I need to concern myself with threading issues in shared functions in an ASP.Net application?In my head; let's say my application namespace is MyTestApplicationNamespace. Everytime a new user connects to my site a new instance of the MyTestApplicationNamespace is created and therefore all shared functions are common to that instance and user but NOT common across multiple users. Is this correct?
View 2 Replies
Mar 30, 2010
See in below I have writtine a
1. Singleton class Emp1 with Display Method and
2. Static Class with Static Method Display.
What is the advantage of singleton class over Static Class with Static members?
[Code]....
View 9 Replies
Aug 17, 2010
I have an app that I am testing with NUNit. The project im testing has several helper classes that are created as public static readonly. When I run the NUnit tests, they all fail with the same error
Systems.Code.Test.TransactionTest.CreateDataContext_ConnectionString_ReturnsDataContextObject:
View 2 Replies
Feb 4, 2011
I am developing a web application, which has Data Access Layer and this layer has only one class, in which all methods are static methods like static Insert, static Update, static Search. It has no properties. I am using these methods in my Bussiness Logic class for my users who are visiting my website.Now my question is : 1. Is it right to use static methods in this scenario ?2. What will happen if 10 users call Insert method at the same time ?
View 3 Replies
Jan 11, 2010
So I started working on my first asp.net application that involves logging in and databases, and soon after i started messing around with a static class. I "discovered" that if you make a variable static, all sessions share that variable (I for some reason was originally assuming that each session had its own copy of that "static" class). Anyway, after discovering this I thought to myself "how could this possibly be useful to me" and thought that itmight be a good idea to make a single static database connection for all of the sessions, rather than storing that as a session variable for each session. Does anybody know what would be the pros and cons of this approach?
View 5 Replies
Aug 25, 2010
is there any impact of using static methods in Business Access layer in 3 tier applciation,
View 4 Replies
Oct 9, 2010
Im trying to implement an unit of work pattern by passing an unit of work instance into my repositories.
Relevant code from Global.asax.
[code]....
What i want is that a maximum of 1 instance of SqlUnitOfWork is created per request and is passed into my repositories (via their respective constructors).
Is the InRequestScope() method on the IUnitOfWork binding enough? If not how can i achieve this?
View 1 Replies
Jun 21, 2010
firstly a static class only ever exists once and is not an instance. Any static members (ie static int NoOfPeople;) is stored in one place and is shared between all sessions (like the old global variables).
Now static methods is where i'm not 100% sure. If I have a static method that doesn't use any other static members could this cause inconstant results, example (this is a fairly pointless method but just a quick example of the top of my head)
[Code]....
So in this example if two sessions (or threads) were to call this at the same time - would they both get back the expected results, because the method only uses private data (a, b and totalToReturn).Im sure this sounds a little simple but I will be using static methods to build user objects and various other objects that there will have to be a 100% garentee that the objects will not get mixed up between sessions and the wrong things return to the user.
View 5 Replies
Feb 7, 2010
I am trying to create a simple page with a drop down list which has 3 items. Choosing any of those 3 items calls for a specific constructor in the script. Using VB 2008
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.Text == "Coupe")
{
//Response.Write("You chose the Coupe");
string Engine;
string Transmission;
string Wheels;
string Safety_Features;
string Key_Systems;
string Interior;
string Mileage;
Altima A1 = new Altima(Engine, Transmission, Wheels, Safety_Features, Key_Systems, Interior, Mileage);
Response.Write(A1.displayAuto());
}
if (DropDownList1.Text == "Hybrid")
{
Response.Write("You chose the Hybrid");
}
if (DropDownList1.Text == "Sedan")
{
Response.Write("You chose the Sedan");
}
}
public class Altima
{
//private member variables
private string Engine;
private string Transmission;
private string Wheels;
private string Key_System;
private string Safety_Features;
private string Interior;
private string Mileage;
//public accessor methods
public void displayAuto()
{
System.Console.WriteLine(Engine, Transmission, Wheels, Safety_Features,Key_System, Interior, Mileage);
}
//constructors
public Altima(string Engine, string Transmission, string Wheels, string Safety_Features, string Key_System, string Interior, string Mileage)
{
this.Engine = Engine;
this.Transmission = Transmission;
this.Wheels = Wheels;
this.Key_System = Key_System;
this.Safety_Features = Safety_Features;
this.Interior = Interior;
this.Mileage = Mileage;
string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque");
string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode");
string Wheels = ("17 inch 5-spoke aluminum-alloy wheels (2.5 S) or 18 inch 5-split spoke aluminum-alloy wheels (3.5 SR)");
string Safety_Features = ("Six standard air bags as part of Nissan Advanced Airbag System (AABS)");
string Key_System = ("Nissan Intelligent Key® with Push Button Ignition");
string Interior = ("Leather");
string Mileage = ("Up to 5.6 L/100 km on city with eCVT");
}//coupe -------> First constructor
public Altima(string Engine, string Transmission, string Safety_Features, string Mileage)
{
this.Engine = Engine;
this.Transmission = Transmission;
this.Safety_Features = Safety_Features;
this.Mileage = Mileage;
string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque");
string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode");
string Safety_Features = ("Six standard air bags as part of Nissan Advanced Airbag System (AABS)");
string Mileage = ("Up to 5.6 L/100 km on city with eCVT");
}//sedan -----------> Second Constructor
public Altima(string Engine, string Transmission, string Mileage)
{
this.Engine = Engine;
this.Transmission = Transmission;
this.Mileage = Mileage;
string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque");
string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode");
string Mileage = ("Up to 5.6 L/100 km on city with eCVT");
}//hybrid -----------> Third constructor
}
}
how do I ouput the values from the constructors when I choose the specific list box item?
View 6 Replies
Jul 14, 2010
my solution in VS 2008, consisting of a dozen projects, does not compile because it gives me errors on constructors of a couple of classes, telling me that lacks the constructor that takes one parameter, which lacks the parameterless constructor, and so on.Actually I have all the correct constructors, and other times I compile without problems.I'm not understand why I have these random problems, that it is practically impossible to replicate.
View 2 Replies
May 10, 2010
Is it safe to access asp.net session variables through static properties of a static object?Here is what I mean:
public static class SessionHelper
{
public static int Age
{
get
{
[code]...
Is it possible that userA could access userB's session data this way?
View 2 Replies
Mar 26, 2011
I have a private static field in my Controller class in an MVC web application.
I have a static method in that controller that assigns some value to that static field, I want to apply lock on that static field until some other instance method in the controller uses the value stored in the static field and then releases it.
DETAILS:
I have a controller named BaseController having a static ClientId field as follows and two methods as follows:-
public static string ClientId = "";
static void OnClientConnected(string clientId, ref Dictionary<string, object> list)
{
list.Add("a", "b");
// I want the ClientId to be locked here, so that it can not be accessed by other requests coming to the server and wait for ClientId to be released:-
BaseController.clientId = clientId;
}
public ActionResult Handler()
{
if (something)
{
// use the static ClientId here
}
// Release the ClientId here, so it can now be used by other web requests coming to the server.
return View();
}
View 1 Replies
Jun 30, 2010
I did some research after posting. All I found was simple examples for no-layer architectures, like connecting to a database from your aspx page, so, in a corporate environment, it is unnaceptable.
I need to call a server-side method (using ASP.NET Ajax) in a 3-layer architecture.
For example, my Default.aspx contains a method LoadProducts().
[Code]....
[Code]....
This cannot change. There is no way to convert Business and Data layers to static.
How can I call the LoadProducts() method using ASP.NET Ajax?
View 2 Replies
Oct 21, 2010
I am trying to come up with the best way to get only certain properties from a type using reflection. How can I differentiate the properties from each other?
I understand that I can use binding flags or name. But say I want only a certain four properties. Would the best way be to create a custom attribute for the ones I want then loop through all of the properties to see if they have that attribute?
View 3 Replies
Jan 29, 2010
I have a class decorated with a attribute ...[DataEntity("MESSAGE_STAGING", EnableCaching = true, CacheTimeout = 43200)] for some requirement,I want to change this value "MESSAGE_STAGING" at run time to "Test_Message_Staging". What is the best possible way to achieve this? Can i use reflection ,Or is there any other way to do this.
View 3 Replies
Mar 21, 2011
I am loading the dll as shown below,
Type[] _Type = Assembly.GetAssembly(typeof(StdAdapter)).GetTypes();
Now I want to get all the properties for a particular 'class name' which is being passed as a string.
View 3 Replies
Mar 19, 2011
I have a collection of assemblies using reflection. I want to loop through them, but I would like to ignore the .NET framework or ASP.NET framework DLL's. Is there an attribute on the assembly that marks that its from the .NET framework? Or any other designation?
I was looking at the name, and if the name of the assembly starts with System, Microsoft, or mscorlib, I am ignoring it. But I was wondering if there is a flag I can use to make this even easier?
View 2 Replies
Jun 8, 2010
I got a strange one here and I want to know if any of you have ever run accross anything like it.
So I've got this web app that loads up a bunch of dll's through reflection. Basically it looks for Types that are derived from certain abstract types and adds them to the list of things it can make.
Here's the weird part. While developing there is never a problem. When installing it, there is never a problem to start with. Then, at a seemingly random time, the application breaks while trying to find all the types. I've had 2 sites sitting side by side and one worked while the other did not, and they were configured exactly(and I mean exactly) the same.
IISRESET's never helped, but this did:
I simply moved all the dll's out of the bin directory then moved them back. That's right I just moved them out of the bin directory then put them right back where they came from and everything worked fine.
Any ideas?
Got some more info
When the site is working I notice this behavior:
After IISRESET it still works, but recycling the app pool will cause it to break.
When the site is broken:
Neiter IISRESET nor recycling the app pool fixes it, but
moving a single dll out then back in fixes it.
Even More Info
So it turns out that IsAssignableFrom is not returning the correct value. I would not have believed it to be true, but I had my logger log the result and the 2 types, and it definitely returned the wrong value. The crazy thing is that the same dll will return different values at different times when comparing the same 2 types. Yet More Info The particular class that IsAssignableFrom fails on in located in a file with other classes. If I move the class to its own file, then everything works fine. However, if it is in the same file as other classes(even if it is in its own namespace block) then the Type reference is all wrong. The Type reference will have the correct name and methods, but it has trouble finding the correct constructor.
View 3 Replies
Apr 29, 2010
i am trying to implement a generic method which allows to output csv file
public static void WriteToCsv<T>(List<T> list) where T : new()
{
const string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
[Code]....
but I am not able to get the value of the object's property
View 2 Replies
Mar 12, 2010
i have one interface . for which i need to send the input.input can be differe for person to person .i want to create a custom section in app.config .
<customsection url="">
<value1>
<value2>
</customsection>
for this i can create a libaray and do it ..many different libarray for many people with interface inclued in all ..this is want i need to do ...but the problem for me s i dont know wat library he s going to give me .. client will give me only the dll and i hv find the class name and its corresponding custom sectipon and call the interface method and get the output ..Reflection s the way but i dont know how to do it ...
View 2 Replies