Add-ons for your C# app - c#

I have a C# program and I want to make it able to load addons. Addons are like that: You pass a control or form to it and it makes some changes to them.
Is there anyway to have dll addons and load them dynamically at runtime and pass controls??
If not Any Idea? What should I do?

Look into MEF to load and import the assemblies and the controls.

Look at Management Extensibility Framework.

Yes that's possible and it works similar to other programming languages: Load the library and call methods to get names and stuff. One possible solution can be found in this question.

Related

control a wpf from matlab by using a c# dll

i would like to know weather it is possible to control some wpf application written in c# by using a c# dll out of matlab.
what i need is the possibility to start the MainWindow and i have to be able
to get some values into my controller.
What i found so far was things working from c# that use matlab, but the other way round seems not to be that much populatet, as i found nothing i could really use.
I allready tried to import a .net Library, but i dont seem to be able to open a external class from my dll.
So if you could help me on this it would be great.
Regards,
justSomeone
Ok, i did just find out, that i can also import my .exe file into Matlab instead of only dlls .
I am using the function NET.addAssebly('Path.exe') to do this.
Path.exe is just a symbol that it is directed to the place of the .exe file.
I achieved to be able to use my methods as i wanted i do have my instance of the class. So i am happy now. :D
But if you have other solutions which are more handy, dont hesitate to post them. There might still be interesting things to discover :)
Regards,
justSomeone

Clr dll .net control

I need to dynamic loading some .NET control from DLL in runtime from C# winforms host project.
for example:
1.dll contrains control1
2.dll contrains control2
3.dll contrains control3
host app may load any of this dll-s, get controls from dll and put it on self form.
I tried:
__declspec(dllexport) TestCLRPlugin::Properties ^ GetControl()
{
return gcnew TestCLRPlugin::Properties();
}
but, clrcall methods can't be exported from dll.
You need to use the Assembly.LoadFrom methods and then you can use reflection to get the method/class/etc you want from the assembly. There are pretty good examples if you follow the MSDN link.
I'm not sure quite what you're looking for, but you may want to read up on reflection, which makes this pretty easy:
http://msdn.microsoft.com/en-us/library/ms173183(v=vs.80).aspx
Sorry if you're already familiar or that doesn't help.

Possible to inject resource files into .net assembly?

There's a .net program for students that I've been messing around with in Reflector and Reflexil, but it doesn't look like they can work with resource files. I want to replace the default background with a custom one. How feasible is this?
I've tried exporting the assembly as a C# project and maybe rebuilding with the resource files swapped, but a few classes won't decompile right when exporting and crashes Reflector when I try to view the full source code inside reflector (after clicking 'expand methods')
What type of applicaiton is it? WinForms, WPF, Silverlight, Web? You can do it with ILDasm round triping. If you let me know what type of app it is I'll post the steps you need to take.
Reflexil 1.3 is now able to handle resources.
Quite difficult, probably Hex Editor can help.
Resource Hacker can do it. Follow; Action > Add a new Resource
delphi.icm.edu.pl/ftp/tools/ResHack.zip
I just put out GrayWolf to edit programs, I don't have the ability to edit resource(s) (if you donate$:) yet
but I would think the easy change is to edit the program to load the background from disk (./back1.jpg)
I have others tools that would make it easy to change the background of the running program see
"Hacking .NET" at DefCon18
other tools "GrayDragon"
I have a payload that does just this, it is for DefCon19, but if you send me an e-mail...
Happy hunting

How do I serialize a .NET control to CODE?

I want to create a .NET Form at runtime, add buttons and other controls to that (also at runtime), and then be able to generate a something.designer.cs file from that form (which can then be added to a C# solution and compiled).
What I want to do is very similar to what the WinForm designer does. But instead of having a drag/drop interface for the user, I want to dynamically build the Form/Controls myself at runtime.
I was thinking I could just reuse what the WinForm designer is doing.
Is that possible?
This MSDN magazine article should have everything you need.
It's really not as simple as it was pre-.NET as the visual version of the form you see in Visual Studio is actually the result of multiple files.
But in the simplest form you could simply just mirror what .NET does at the start of creating a new form:
Create three files Form.cs, Form.Designer.cs and Form.resx (which is an XML file).
Place the same default content in them that VS does
Mimic the code generated when adding controls, code-behind and resources
It will be a tedious task, but it can be done. Adding resources however will be burdensome.
Yes, you can do achieve this using Compiler Services (compiling c# code) or Emit class if you know building correct MSIL.

I want to use an exe file programatically

I am using a software named Daisy 2.02 Validator and it is with GUI but i want to access it programatically so that i can control all the validation process through my C# project. I am unable to find any help about it's libraries, any .net Api or any DOS command for controlling it. Please provide me help.
Thanks,
Regard,
Muhammad Waqas
If it's a .NET executable, try and use ILDASM.exe or better still - use Reflector to find out whether it has a public API. You may then be able to add it as a reference (all you need to do is simply rename the .exe to .dll) to your project or alternatively load it as an assembly and use reflection to use its API.
Obviously the first option is much preferred.
If it isn't a .NET executable, you could use scraping, but you would have to profile your app for that first and work out what low level windows messages and controls it responds to. Bit of a nightmare.
from what I see Daisy 2.02 Validator is an open source project.
if the API is not implemented you can just add it yourself
Worst case maybe send keystrokes to it.

Categories