473,405 Members | 2,334 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,405 software developers and data experts.

Sharing plugins between two C# applications

Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used some
classes and functions which were compiled into the main executable. So I had
to compile them by hand, adding the main executable as reference to the
csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the Activator.GetInstance()
function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent
Aug 9 '06 #1
7 3160
Laurent,

The problem here is that you are referencing the main executable from
your plug in. The point of a plug in is to have the implementation of the
plug in be separate from that of the main program it is being included in.
By setting a reference to the main executable, you aren't decoupling the
program at all.

What you should do is take the functionality in the main executable that
is needed by the plug in and place it in a library. Then, have the plug in
and the executable reference the library.

Then, you should be able to use the plug in in each application just
fine.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Laurent Navarro" <yo*@yop.comwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used
some classes and functions which were compiled into the main executable.
So I had to compile them by hand, adding the main executable as reference
to the csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the Activator.GetInstance()
function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent

Aug 9 '06 #2
I think the proper way to support application plugins is for the
application to define Interfaces which the plugins must implement.
Then the application needs to know that the plugin exists, so it can
load it. The loading should be generic though, so that all plugins
must implement some kind of interface defined by the application.

In order to share plugins, both your applications MUST specify the same
interfaces. So you'll likely need to move the interfaces to a seperate
assembly, and each application will reference the assembly which
comtains the interfaces.

Your plugins would ONLY reference this assembly which contains the
interface definitions.

HTH
Andy

Laurent Navarro wrote:
Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used some
classes and functions which were compiled into the main executable. So I had
to compile them by hand, adding the main executable as reference to the
csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the Activator.GetInstance()
function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent
Aug 9 '06 #3
Thanks Nicholas and Andy for your quick answer, I understand that I must
create an assembly that both the plugins and the applications will reference
when compiling.

I already created an abstract PlugIn class which is the base class for
all of my plugin (it is not only an interface as I have some functions in
it). Because I want my plugin to interact directly with the GUI of my
applications, I have a reference to my main form in the PlugIn class.

Of course, when I try to compile my abstract PlugIn class into an
assembly, it doesn't want because he can't find the reference to my main
form.

I'm begining in assemblies, what should I do ?

Thanks !



"Laurent Navarro" <yo*@yop.coma écrit dans le message de news:
O9**************@TK2MSFTNGP02.phx.gbl...
Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used
some classes and functions which were compiled into the main executable.
So I had to compile them by hand, adding the main executable as reference
to the csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the Activator.GetInstance()
function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent

Aug 9 '06 #4
You have to rework the abstract class so that a refernce to the main
form is no longer required.

If there is something unique to your main form that's not in the normal
Form class, you could create an interface in your plugin definition
assembly, and have your plugin require it be passed an instance object
which implements that interface. Your main applicaton already has a
reference to this shared plugin definition assembly, so you can easily
make your form implement this interface. That will decouple
everything..

Andy

Laurent Navarro wrote:
Thanks Nicholas and Andy for your quick answer, I understand that I must
create an assembly that both the plugins and the applications will reference
when compiling.

I already created an abstract PlugIn class which is the base class for
all of my plugin (it is not only an interface as I have some functions in
it). Because I want my plugin to interact directly with the GUI of my
applications, I have a reference to my main form in the PlugIn class.

Of course, when I try to compile my abstract PlugIn class into an
assembly, it doesn't want because he can't find the reference to my main
form.

I'm begining in assemblies, what should I do ?

Thanks !



"Laurent Navarro" <yo*@yop.coma écrit dans le message de news:
O9**************@TK2MSFTNGP02.phx.gbl...
Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used
some classes and functions which were compiled into the main executable.
So I had to compile them by hand, adding the main executable as reference
to the csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the Activator.GetInstance()
function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent
Aug 9 '06 #5
"Laurent Navarro" <yo*@yop.comwrote in message
news:un**************@TK2MSFTNGP03.phx.gbl...
I already created an abstract PlugIn class which is the base class for
all of my plugin (it is not only an interface as I have some functions in
it). Because I want my plugin to interact directly with the GUI of my
applications, I have a reference to my main form in the PlugIn class.

Of course, when I try to compile my abstract PlugIn class into an
assembly, it doesn't want because he can't find the reference to my main
form.
You can define an interface that the main form implements, and the interface
definition can be separated from the main application. Then at runtime you
pass your form instance, which implements the interface, to your plugin.

-- Alan

Aug 9 '06 #6
Laurent,

You should still do what I recommended.

What you need to do is create an interface that the main form will
implement which exposes the functionality. Then, you pass that interface
definition to your plug in. Of course, the interface is defined in the
assembly that is referenced by the plug in and the main application.

Either that, or pass the type System.Windows.Forms.Form to your plug in,
instead of the typed version.

It's actually a really bad idea to allow plug ins free reign like this.
You should have a constrained set of functionality that the form implements
and exposes through the interface definition and then pass that to your plug
in.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Laurent Navarro" <yo*@yop.comwrote in message
news:un**************@TK2MSFTNGP03.phx.gbl...
Thanks Nicholas and Andy for your quick answer, I understand that I
must create an assembly that both the plugins and the applications will
reference when compiling.

I already created an abstract PlugIn class which is the base class for
all of my plugin (it is not only an interface as I have some functions in
it). Because I want my plugin to interact directly with the GUI of my
applications, I have a reference to my main form in the PlugIn class.

Of course, when I try to compile my abstract PlugIn class into an
assembly, it doesn't want because he can't find the reference to my main
form.

I'm begining in assemblies, what should I do ?

Thanks !



"Laurent Navarro" <yo*@yop.coma écrit dans le message de news:
O9**************@TK2MSFTNGP02.phx.gbl...
> Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used
some classes and functions which were compiled into the main executable.
So I had to compile them by hand, adding the main executable as reference
to the csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the
Activator.GetInstance() function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent


Aug 9 '06 #7
Thanks guy, I tried what you said and it's seems to be working !!

"Laurent Navarro" <yo*@yop.coma écrit dans le message de news:
un**************@TK2MSFTNGP03.phx.gbl...
Thanks Nicholas and Andy for your quick answer, I understand that I
must create an assembly that both the plugins and the applications will
reference when compiling.

I already created an abstract PlugIn class which is the base class for
all of my plugin (it is not only an interface as I have some functions in
it). Because I want my plugin to interact directly with the GUI of my
applications, I have a reference to my main form in the PlugIn class.

Of course, when I try to compile my abstract PlugIn class into an
assembly, it doesn't want because he can't find the reference to my main
form.

I'm begining in assemblies, what should I do ?

Thanks !



"Laurent Navarro" <yo*@yop.coma écrit dans le message de news:
O9**************@TK2MSFTNGP02.phx.gbl...
> Hello,
I created a software some times ago, which uses some plugins to work
(which I coded also). I had problems to load those plugins as they used
some classes and functions which were compiled into the main executable.
So I had to compile them by hand, adding the main executable as reference
to the csc.exe command line. It worked.

Now, I would like to create another application which would use the
same plugin. If I link the old ones with my new software, I have an error
saying that the DLL could not be loaded. I use the
Activator.GetInstance() function...

My question is: is there a way to share my plugins between my
applications without having to compile them each time with a difference
reference to the main executable ?
Thank you for your help !

Laurent


Aug 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
1
by: John Baker | last post by:
Hi: I have an application that is getting pretty bloated, and I want to develop new, infrequently used, sections of it ( specifically special report generation) as a separate file from the...
5
by: Michael McCarthy | last post by:
I want to develop plugin support for a system.montitor module I am working on. A lot of the modules will do mostly interop stuff for an older system, but I want to use it myself as well to monitor...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
3
by: Shikari Shambu | last post by:
Hi All, I have a situation where multiple applications are sharing some pages/ controls. So, I have a separate common project that has the common pages/ controls. My question is how do I...
4
by: qube3 | last post by:
We have applications written by JSP/Servlet and ASP.NET. All our future development would be based on ASP.NET. We wants to develop a single user interface so that users would not be aware that...
1
by: dgiagio | last post by:
Hi, I'm developing an application using the C language and Python for it's plugins. The C program connects to a MySQL database and keeps that connection active. Is it possible to 'share' this...
1
by: sergio montero | last post by:
Hi, I've been searching for books or tutorials that help to undestand better the way plugins work and how they should be programmed, but I just found a few articles about the basis (interfaces,...
9
by: Peri | last post by:
Dear All, Is there a way in which 2 application can share a common memory location to access static data? Say for example I have a product master data that is available in a single place, and...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.