Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
AnswerRe: Unit test of Asynchronous Block not happening Pin
Nicholas Marty28-Oct-15 5:02
professionalNicholas Marty28-Oct-15 5:02 
GeneralRe: Unit test of Asynchronous Block not happening Pin
Ashfaque Hussain28-Oct-15 21:52
Ashfaque Hussain28-Oct-15 21:52 
QuestionFonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Prem9527-Oct-15 23:14
Prem9527-Oct-15 23:14 
SuggestionRe: Fonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Richard MacCutchan27-Oct-15 23:35
mveRichard MacCutchan27-Oct-15 23:35 
AnswerRe: Fonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Gerry Schmitz28-Oct-15 6:35
mveGerry Schmitz28-Oct-15 6:35 
QuestionNot allowed to change the 'ConnectionString' property. The connection's current state is connecting. Why I am getting this error? Pin
Member 1200209527-Oct-15 20:09
Member 1200209527-Oct-15 20:09 
AnswerRe: Not allowed to change the 'ConnectionString' property. The connection's current state is connecting. Why I am getting this error? Pin
John Torjo27-Oct-15 21:55
professionalJohn Torjo27-Oct-15 21:55 
QuestionPlugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
jappi8827-Oct-15 7:04
jappi8827-Oct-15 7:04 
Hello guys/gals,

Since a few months i have rather a real head desturbing issue :/

I have developed a plugin architecture that exists of a Host app and several plugins.

The host app basicly loads all the plugins availible, and allows any plugin to interact with the host, and vice versa.
Everything works fine when it comes to using methods/properties ect...accept for the events...

The events are used to send info to any asigned instance, including the plugins.
Whenever i assign the event inside plugin to recieve info from the host then i get the 'System.Reflection.TargetInvocationException'.

The exception is thrown whenever the host invokes the event that has been assigned from plugin instance.
Though i should mention that the event is used by the plugin AND the host.
They both should be revieving the plugin info...

I know ive used several events in a plugin system before, but that was the other way around.
The host was recieving info from plugin , witch works, just the other way arround seems to be a issue.


The Plugins are loaded by system.reflection as raw data and not as a file...
i did this because the plugins are stored in a custom container, compressed and encrypted.

Here is the manager interface (HOST):
C#
public interface IPluginManager : IPluginBase
    {
        bool IsLoaded { get; }
        Settings AppPreferences { get; }
        ILogin Server { get; }
        byte[] Signature { get; }
        AppInfo[] Plugins { get; }
       // IPluginLoader[] MountedPlugins { get; }

        #region Events

        event PluginRequestHandler PluginUpdate;
        event PluginRequestHandler PluginInstall;
        event PluginRequestHandler PluginRemove;
        event PluginInstallHandler PluginsToInstall;
        event PluginInstallHandler PluginsToUpdate;
        event PluginInstallHandler PluginsToRemove;
        event PluginHandler PluginActionChanged;
        event PluginsHandler PluginsInstalled;
        event PluginsHandler PluginsUpdated;
        event PluginsHandler PluginsRemoved;
        event EventHandler ManagerLoaded;
        event EventHandler ManagerLoading;
        event EventHandler ManagerDisposed;

        #endregion

        #region Methods

        //TInterface GetPlugin<TInterface>(AppInfo info) where TInterface : class;
       // IPluginLoader GetPluginLoader(AppInfo info);
        void LoadAsync();
        void Dispose();
        void RemovePluginAsync(AppInfo plugin);
        bool RemovePlugin(AppInfo plugin);
        void InstallPluginAsync(AppInfo plugin);
        bool InstallPlugin(AppInfo plugin);
        bool InstallNewPlugins();
        void InstallNewPluginsAsync();
        void MountPluginAsync(AppInfo info);
        void UnmountPluginAsync(AppInfo info);
        void EnableApp(AppInfo info);
        void DisableApp(AppInfo info);

        AppInfo[] GetOnlineApps();

        #endregion
    }


Here the code from plugin instance that init the Host event.
C#
private void MainForm_Shown(object sender, EventArgs e)
{
    if (Host != null && Host.PluginManager != null)
    {
        SCManager = Host.PluginManager;
        SCManager.PluginActionChanged += X_PluginActionChanged; //Add event to Host
        Server = SCManager.Server;
        if (Server == null)
        {
            var x = SCManager.Plugins.FirstOrDefault(t => t.Type == 1);
            if (x != null)
                SCManager.MountPluginAsync(x); //The event should be triggered after this process is complete on the host.
        }
    }
    OnWindowShown(this);
}


Here is the Code that triggers the event:
C#
protected virtual void OnPluginActionChanged(AppInfo info,PluginActionType action,Exception error = null,object param = null)
{
    PluginHandler handler;
    lock (_eventlock)
        handler = _PluginActionChanged;
    handler?.Invoke(this, info, action, error,param);
}


I really hope someone inhere can point me to the right direction, as i'm totally lost...

Thanks! and sorry for my bad english, let me know please if you guys/gals have any more question.
AnswerRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
Eddy Vluggen27-Oct-15 7:48
professionalEddy Vluggen27-Oct-15 7:48 
GeneralRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
John Torjo27-Oct-15 10:59
professionalJohn Torjo27-Oct-15 10:59 
GeneralRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
Eddy Vluggen27-Oct-15 12:36
professionalEddy Vluggen27-Oct-15 12:36 
QuestionWhy my .NET application is crashing?! Pin
Jassim Rahma26-Oct-15 23:42
Jassim Rahma26-Oct-15 23:42 
AnswerRe: Why my .NET application is crashing?! Pin
Pete O'Hanlon27-Oct-15 0:00
mvePete O'Hanlon27-Oct-15 0:00 
AnswerRe: Why my .NET application is crashing?! Pin
John Torjo27-Oct-15 1:45
professionalJohn Torjo27-Oct-15 1:45 
AnswerRe: Why my .NET application is crashing?! Pin
Dave Kreskowiak27-Oct-15 2:29
mveDave Kreskowiak27-Oct-15 2:29 
QuestionWorking on multithreading application Pin
Member 1132358526-Oct-15 23:39
Member 1132358526-Oct-15 23:39 
AnswerRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 1:23
professionalDaniel Pfeffer27-Oct-15 1:23 
GeneralRe: Working on multithreading application Pin
BillWoodruff27-Oct-15 3:29
professionalBillWoodruff27-Oct-15 3:29 
GeneralRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 4:05
professionalDaniel Pfeffer27-Oct-15 4:05 
AnswerRe: Working on multithreading application Pin
Foothill27-Oct-15 4:30
professionalFoothill27-Oct-15 4:30 
AnswerRe: Working on multithreading application Pin
Gerry Schmitz27-Oct-15 7:23
mveGerry Schmitz27-Oct-15 7:23 
Questionnew to C# Pin
Member 1206164726-Oct-15 18:39
Member 1206164726-Oct-15 18:39 
AnswerRe: new to C# Pin
Garth J Lancaster26-Oct-15 19:34
professionalGarth J Lancaster26-Oct-15 19:34 
AnswerRe: new to C# Pin
John Torjo26-Oct-15 19:51
professionalJohn Torjo26-Oct-15 19:51 
AnswerRe: new to C# Pin
OriginalGriff26-Oct-15 22:50
mveOriginalGriff26-Oct-15 22:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.