Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a program that I am making for a friend and I don't want him to see the whole code, but I want him to be able to add classes that have attributes on the classes so he can add his own stuff to it, how would I be able to get classes using a compiled program and add them to the dictionary of methods to be called upon later?
Use MEF.
The Managed Extensibility Framework or MEF is a library for creating
lightweight, extensible applications. It allows application developers
to discover and use extensions with no configuration required. It also
lets extension developers easily encapsulate code and avoid fragile
hard dependencies. MEF not only allows extensions to be reused within
applications, but across applications as well.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Is it possible to raise an event in one .dll that can be handled by another? If so, what should I be looking at.
EDIT:
I think the two dlls are running in the same process - they are both add-ins to another program. I'm limited to what I can do with add-ins, hence the need to have this communication.
I thought about writing to a local file and reading it from the other dll, but how would I know when to read it.
It's called Interprocess Communication
You probably would like to look on Pipes, or look into the IpcChannel Class, which may make things even easier. I personally didn't use any of those under C# language, but what important, is an idea and technology behind, the rest is an implementation detail.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This might seem like a very trivial question to more experienced c# developers but please keep in mind I'am a beginner to the c# language but getting through it very well.
However I have came to a stumbling block regarding creating c# classes. I understand the whole concept of the intrinsic details on how to create the class i.e class is like a blueprint in which you create objects from in which there data is stored in fields in which you use constructors to initialize them (or default) and behaviours are performed in the form of methods bla bla etc etc.
However the question that I have is in regards to the purpose of creating your own classes in c#. I was wondering if we create our own classes like the ones that are available in the .net framework, I.e if the .Net framework hasn't got a class that wee need, so do wee then just create our own class defining the functionality that I need.
Is this the only purpose of creating classes or is this way more focused on creating DLL's, and I am missing something ?
Any ideas tips hints or expansions would be great (in laymen's Terms).
if the .Net framework hasn't got a class that wee need, so do wee then just create our own class defining the functionality that I need.
Yes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
There is a big windows application in which we also have WPF, I need to create an addin so that i can move my hige client to small addins. Problem is i need to pass commands or want to talk to other windows of the existing application from the addin. I have tried plugins which i have loaded through reflection. but how do i communicate to the other windows of the existing application?
You don't communicate with other windows directly. If you need an architecture like this, have a look at Prism for instance. And for communication between modules/add-ins you either use some sort of events (Prism has EventAggregator) or you provide interfaces in a project common to all other projects, and use dependency injection like MEF to provide modules with implementations of those interfaces. I know this is a very broead answer and you'll stil have to learn a lot, but your question is equally broad and there's just no way you can learn how to deal with large scalable applications in one-two-three. Or a couple of days/weeks.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
due to unit-testing we create for every class an Interface. The .Net Framework coding standards say that every class, interface, enum, etc. should be located in a different file.
As these interfaces are so closely related with the class we were thinking of creating an internal coding-standards rule to put together the class and the interface.
Have you seen this approach before? What do you think about it?
PD: Always talking about interfaces used only to mock the classes, not 'real' interfaces that can have more than one implementation.
You should follow .NET coding standards and separate the interfaces into their own files. You could create a folder Interfaces within your project. I usually have Concrete, Abstract and Interfaces folders within my projects.
Developers who may be unfamiliar with your solution will have a hard time finding interfaces if they are in class files.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm working on a project in C#, it's about E-learning.This project should use plug-ins as its main inputs, it can't function without them.
I have no idea how can I work with plug-ins, I know nothing about how can a plug-in compile inside my program, or how can I install them inside my application.
I'm asking here about references, or any useful ideas that can help me with this.
Start by creating a Plug-In Interface:
public interface IPlugIn
{
// Your stuff here
}
You can then distribute your interface to the developers working on the plugins.
When your application starts up, it can load all Plug-In assemblies dynamically, then work with them through the IPlugIn interface without needing to know the internals of each one.
UPDATE
I actually found an article that goes into the process I described in more depth with more ellaborate examples. You can check it out here:
Writing Plugin-Based Applications in .NET
And an added bonus...it comes with Code Samples!
if your plugin is not too complex you can avoid using extensibility frameworks like MEF.
You define contract for plugin. It should be public interface, or may be class with abstract/virtual methods. You should move it to separate assembly and distribute to plugin developers
Developers implement interface and produce assemblies
Use Assembly.Load to load in runtime.
List types by GetTypes
Find types that implement your interface
Activator.CreateInstance
Have fun