need help for exeption issue

Oct 21, 2013 at 8:21 AM
Edited Oct 21, 2013 at 8:47 AM
Hello,
I am using CInject but having trouble with something that i couldnt find the solution. I need your opinion. Hope you can help me about this issue.

Injecting CInject.Injections.dll is working without any exeption. But when i inject the dll that you gave us on documentation site, that sample dll gave me exception i attached below.

using System;
using CInject.Injections.Interfaces;

namespace MyApplication
{
public class MyLogInjector : ICInject
{
    #region ICInject Members

    public void OnInvoke(CInjection injection)
    {
        try
        {
            Console.WriteLine("Hey, I am called with following values-");
            for (int i = 0; i < injection.Arguments.Length; i++)
            {
                Console.WriteLine(String.Format("    [{0}]: {1}", i, injection.Arguments[i].ToString()));
            }                
        }
        catch
        {
            throw;
        }
    }

    public void OnComplete()
    {
        Console.WriteLine("Hey, I have finished working! Good Bye!"); 
    }

    #endregion
}

}

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at MyApplication.MyLogInjector.OnInvoke(CInjection injection)
at WotC.MTGO.Client.CustomUI.DlgTradeAcceptInvite.HandleReaction(Object objReacting, eACTION eReaction, Object[] args)
at WotC.MTGO.Client.CustomUI.DialogManager.Activate(Dialog dlog)
at WotC.MTGO.Client.CardCollection.DOTradeController.Start_DlgTradeAcceptInvite()
at WotC.MTGO.Client.CardCollection.DOTradeController..ctor(Trade trade)
at WotC.MTGO.Client.Network.Network_Manager.#e9c(Object sender, Trade trade)


************** Loaded Assemblies **************
Coordinator
Oct 22, 2013 at 6:05 PM
This is because one of the arguments received in the OnInvoke may be null
for (int i = 0; i < injection.Arguments.Length; i++)
            {
                if (injection.Arguments[i] == null) continue;

                Console.WriteLine(String.Format("    [{0}]: {1}", i, injection.Arguments[i].ToString()));
            } 
Alter the code as advised above
Oct 22, 2013 at 9:10 PM
I recognized your logger not throw same error so i checked your loginject.cs it also gave me the answer.
Thank you for responding .
Regards
Erdem