Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Question: Is it possible to register one .net assembly to pick up events from another assembly easily?

At the moment for communication between two assemblies I am using remoting, which works fine, but am just wondering if I'm making too much of a meal of it.

Just wondering if .Net has something in the background to handle it in a more seamless fashion...?

Anyone? Cheers

Julian
Posted
Comments
Albin Abel 19-May-11 6:35am    
Needs more information about are these assemblies runs in the same process or different, same domain or different. Also little more explanation of the task you are trying to achieve. Thanks
julian@giant 19-May-11 6:46am    
Hi Albin, Ok, a wider explanation of what I am currently doing is:

Two separate .exe's running on a server by multiple users need to talk to each other and pass some information to and from one another.

The project is a Document Management System (DMS) where one program handles the viewing of all types of office documents, and the other is a Workflow program that handles incoming documents (either scanned images or word/excel documents that may have been emailed). I wanted the Workflow program to keep separate from the Office Dll's etc and call over to the DMS to view and save the documents, as that is what it does already.
I need to pass information about the document from the WF program to the DMS program basically.
As I say, I'm currently using remoting, but just wondered if anyone new of a simpler way.

What brought me to this question was the realisation that I can register my DMS .exe code to pick up events directly from Office documents (VB.Net - ... Handles wdApp.BeforeClose() etc.). Just wondered if the same could be achieved between .Net .exe's.

Julian

First things to know: there is no barriers between assemblies (unless you artificially create barriers changing assembly permissions). Whatever you can do in one assembly, you can do in reference assembly. You only need to use public or protected (within the same class hierarchy) access modifiers while withing a single assembly you need only internal or internal protected access.

(If you really need to load assemblies dynamically instead of referencing them (I refer to the answer by Abhinav, as your request is not clear at all, you need to develop some plug-in technique. For this purpose, I have comprehensive directions given in my past answers:
Create WPF Application that uses Reloadable Plugins...[^].
AppDomain refuses to load an assembly[^].
Don't think it's too complex. Most likely, you don't need the hard part of it related to the unloadable stuff and hence Application Domains.)

—SA
 
Share this answer
 
v3
Comments
Abhinav S 19-May-11 23:37pm    
Good explanation. My 5.
Sergey Alexandrovich Kryukov 19-May-11 23:56pm    
Thank you, Abhinav.
--SA
You could consider using Reflection.
 
Share this answer
 
Comments
julian@giant 19-May-11 5:10am    
Hi Abhinav

I take it that using Reflection would still require an intermediary .dll?

Julian
Abhinav S 19-May-11 6:08am    
You can just load the second assembly into your first one as shown at http://support.microsoft.com/kb/837908 - but I think I see your point if I understand it correctly.
Sergey Alexandrovich Kryukov 19-May-11 13:51pm    
No need in it! Can you explain why?
--SA
Sergey Alexandrovich Kryukov 19-May-11 13:58pm    
OK, I put comprehensive explanation and cover dynamic loading as well in my solution.
Please see.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900