|
Thanks for your replies and useful tips Roger and Pete!
|
|
|
|
|
You are welcome, and good luck.
|
|
|
|
|
You're quite welcome!
Will Rogers never met me.
|
|
|
|
|
Actually, if you are compiling against .NET 3.5 so that your code works with 3.5 AND 4.0, then the issue is likely that you are using server-side components.
.NET 4.0 is broken up into a Client Profile and Extended versions.
.NET 4.0 by default only installs the Client Framework when installed on a client machine. Server-side (defined by Microsoft) components are not included (to keep the install size down). You can install them with the .NET 4.0 EXTENDED Framework, after which I would expect your service to work.
If you set your compile target to .NET 4.0 Client Profile, you can discover which components are missing (because they are only in extended in 4.0), and possibly remove them if you want it to work with the 4.0 Client Profile.
|
|
|
|
|
Since your application is compiled for both .NET 3.5 and 4.0, you will need both installed. If you want to run on a system that only has 4.0 installed, you will need to recompile all of your projects (of the service or application) using .NET 4.0. Look at all of the responses for more ideas.
|
|
|
|
|
I am developing a system that I'm trying to keep as generic as possible.
It is capable of implementing/executing business rules that should be defined in another file/assembly.
For sake of explanation, I'll segment the idea into the "generic system" and "business system".
If the "business system" were to change or require an update, then that should be possible without releasing the "generic system".
Let's say the generic system monitored a folder, and if a file associated with the new version of the business code was dropped into that folder then it would be accessed, and if the version was > than the current one, then the generic code would start using it.
The business code could have a factory method like GetEventProcessor(guid) that would return a delegate (from the "business system" (with a consistent signature) that is associated with the guid passed into GetEventProcessor.
I'm looking for examples of or ideas about a mechanism whereby code with a defined interface can be picked up and integrated into execution of another piece of code at run time.
I have found some articles about plug-in based architectures in .net. Developing this type of system is new to me, and as I peer down the barrel of this possibility, I thought I'd pose the question here in hopes of harvesting some opinionated guidance, warnings and/or advice.
Any ideas are welcome.
Thanks
Todd
|
|
|
|
|
|
Presumably there is a business reason driving this.
First step is to define exactly what a 'rule' does. It can't do everything in the known universe because it isn't possible for a consumer to code to such a requirement. So it has to be restricted to some sort of interface (not necessarily meaning the keyword but possibly meaning that) which the consumer knows how to use and manage.
That is a design step not an implementation step.
After you know what that looks like then you might want to look at the Microsoft Addin.
http://msdn.microsoft.com/en-us/library/gg145020.aspx[^]
Although it might be better to write one yourself.
|
|
|
|
|
todd.01011101 wrote: I'm looking for examples of or ideas about a mechanism whereby code with a
defined interface can be picked up and integrated into execution of another
piece of code at run time.
Most KISS solution I can come up with would be an application that simply polls the directory and which processes every file - getting the processor based on the extension of the files. Aw, the most KISS-way of building a processor would be a console-application that generates output, simply passing the path as an argument.
Would be quite easy to maintain and extend, in any language
Bastard Programmer from Hell
|
|
|
|
|
Since you are planning on versioning your logic, you will run into a .NET limitation that you cannot unload code once it is loaded into an app domain[^]. This is regardless of the plug-in discovery mechanism that you choose.
One way around this limitation is to run your plug-ins in separate app domains, unloading the entire app domain once you need to load the next version of a particular plug-in.
Since you cannot make plain old calls across app domain boundaries, so you'll need to design your interface carefully to avoid spending excessive time serializing and deserializing parameters and return values.
Here is the method I use to access items loaded into separate app domains: CreateInstanceAndUnwrap[^].
|
|
|
|
|
I don't expect *too much* churn of the plug-ins, (1, maybe 2 in a day) and the app domain is cycled every night by default so I'm not too worried about the old plug-ins stacking up and causing memory/performance issues. (If I've misinterpreted the outcome of the limitation you described, please set me straight).
That being said, thanks so much for your answer. I'm so glad I posted this here, I've got some great information, and great leads to follow.
I've been reading with eyes wide open all afternoon.
Todd
|
|
|
|
|
todd.01011101 wrote: I don't expect *too much* churn of the plug-ins, (1, maybe 2 in a day)
Every day?
Or when it occurs every 6 months it might involve 1/2?
If the first then perhaps you should look into some entirely different options such as scripting.
|
|
|
|
|
Yes, I meant that the maximum would be 1/2 in a day, but maybe once every few months.
Certainly not 1 or 2 every day.
|
|
|
|
|
You could look at writing dynamic assemblies or methods Using Reflection Emit
"You get that on the big jobs."
|
|
|
|
|
Ok, but how would you know what code to create dynamically? You would still need a mechanism to define the logic so it could be created dynamically. Sorry, not a very good suggestion for the problem, there are far easier methods that are more performant.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have used Castle Windsor[^] to accomplish something similar. There are several other .NET inversion of control containers that may also work (StructureMap, Spring.Net, Ninject, etc.) but I don't have any experience with them.
Regards,
Eric
|
|
|
|
|
Given your rate, 1/2 every 6 months, I doubt a generic system is going to provide an advantage.
|
|
|
|
|
What about a scripting engine for the business system/ part of the business system. If you require functionality to be dynamic. It could be scripted and changed on the fly.
|
|
|
|
|
This is what I have used with one of my programs.
1: Have a page on the Internet with the latest version number.
2: When your application loads, read the Internet file version and if it is grater than your application then....
3. You can give the user the option to upgrade now or upgrade now without prompting the user.
4: Download and run a temp upgrade.exe program. Then quit your main application.
5: The upgrade.exe will download the new version (Using the same file names and locations as the old version)
6: Run the (new) main application.
7: End the upgrade.exe program.
|
|
|
|
|
|
Hi everyone.
Long story short I am working on a replacment shell in VB.net, and while i hav most of it sorted i am struggeling with one section.
The system tray. does anyone know how to (or can point me at a site that can help), make a system tray in VB.net (any of the .net languages is fine)
Thanks
Daniel
Edit
I forgot to mention that I know that the class that handels this in explorer.exe is System_trywnd
Hope that helps
modified on Tuesday, June 7, 2011 9:30 AM
|
|
|
|
|
|
no. I am trying to write a replacment windows shell and I have got to the stage where I need to replicate the system tray. The point where notify icons are placed. Sorry my orrigional post obviously wasnt verry clear on that.
Tanks anyway
daniel
|
|
|
|
|
Yeah, so write an implementation of NotifyIcon for your shell as I think the previous poster intended Basically, the interface for NotifyIcon tells you exactly which functionality is needed and how it is implemented. Basically you can use the same interface and supply a new implementation for it specific to your shell.
Edit:
On the implementation, basically what you need is a toolbar which can display icons, has customized menu's for each icon, has tooltips, and perhaps one or two more features. Here too, the NotifyIcon class gives great amounts of information how to implement each feature.
|
|
|
|
|
I am trying to implement a simply task that appears to be amazingly hard to accomplish in .Net: Sorting a column in a datasource bound control (e.g. DataGridView), not based on the underlying values (i.e. simple string comparison on the values) but on some custom rule that I want to define.
I have a DataGridView that is bound to a Bindingsource which in turn is (via Dataview, .Net internal stuff...) bound to a Datatable. This is plain vanilla stuff, out of the box. If I was happy with the default sort behavior, i.e. sorting columns by the values in DataTable, everything would be easy, even automatic.
However, some of the contents in the Datatable is not in a user-friendly format, so it must be formatted for display in the datagridview (e.g. by overriding the CellFormatting event). If I now sort the control by that column, the rows will be sorted by the underlying values, and not by the displayed text, which is bad.
I cannot use the Sort() function nor the IComparer overwrite of the DataGridView since I am working in databound mode. How in the world then can I intercept the sorting mechanism and tell the DataGridView how to sort this column properly?
It strikes me as odd that the standard data source - binding source - control model in .Net appears to have no provision at all for custom sorting! What is even odder is that a primary reason for the whole concept of a BindingSource is just sorting and filtering!
There must be an easier way than writing 1000s of lines of code to create my own DataView or IBindingList derived class that will allow this kind of customization, as recommended in various articles. This seems such a common scenario that I can't believe there is a more elegant way...
|
|
|
|