locked
How to call host function from plugin? RRS feed

  • Question

  • Hello!
    I create a host(main application) and load each plugin in new domain. For using plugin functions I use spetial interface:
    public interface IPluginFunctionality
        {
            void DoIt();

            string GetDomainName();

            List<int> GetNumbers(int start, int finish);

            void Initialize(PluginDelegate plugindelegate);
           
        }

        public delegate string PluginDelegate(string Name, string Value);

    But I want that host application can run plugin functions and plugin can call host function.... For this in interface I create Initialize method. When I add plugin in plugin list I create a pointer(plugindelegate) on ServerFunction.... But it's not work (I think that therefore plugin and host  remain in different domain).  How to solve my problem?

    TIA
    Monday, September 8, 2008 1:48 PM

Answers

  • public class SharedClass:MarshalByRefObject,IHostFunctionality 
        { 
            public SharedClass() 
            { } 
     
            public string GetDomain() 
            { 
                return AppDomain.CurrentDomain.FriendlyName; 
            } 
     
            public string DoSomething(int i) 
            {  
                return (i + 2 ).ToString(); 
            } 
     
            void IHostFunctionality.DoIt() 
            {  
             
                return
            } 
     
            string IHostFunctionality.SomeMethodFromHost(string bugaga) 
            {             
                return bugaga + "_" + AppDomain.CurrentDomain.FriendlyName; 
            } 
     
        } 
    I solve this problem so....

    I use special shared class witch wath inheritance from MarshalByRefObject and  IHostFunctionality(my interface...)
    This object realize host methods....

    • Marked as answer by jack 321 Thursday, September 11, 2008 2:50 AM
    Tuesday, September 9, 2008 1:01 PM

All replies

  • UPPOST
    Tuesday, September 9, 2008 7:11 AM
  • public class SharedClass:MarshalByRefObject,IHostFunctionality 
        { 
            public SharedClass() 
            { } 
     
            public string GetDomain() 
            { 
                return AppDomain.CurrentDomain.FriendlyName; 
            } 
     
            public string DoSomething(int i) 
            {  
                return (i + 2 ).ToString(); 
            } 
     
            void IHostFunctionality.DoIt() 
            {  
             
                return
            } 
     
            string IHostFunctionality.SomeMethodFromHost(string bugaga) 
            {             
                return bugaga + "_" + AppDomain.CurrentDomain.FriendlyName; 
            } 
     
        } 
    I solve this problem so....

    I use special shared class witch wath inheritance from MarshalByRefObject and  IHostFunctionality(my interface...)
    This object realize host methods....

    • Marked as answer by jack 321 Thursday, September 11, 2008 2:50 AM
    Tuesday, September 9, 2008 1:01 PM