Failing to load PCL Interface DLL in release mode

Xam_DeveloperXam_Developer INMember ✭✭

Hi,

I have developed a recorder application for both Android and iOS. The recommended method for such cross platform feature was to use a PCL class.

Hence I have written a Portable class ( as Interface ) and the implementation in the PCL class.

Everything works just fine but only in the developer version. The moment i change it to Release mode and deploy in iPhone, it fails to load the dll. Since it is an interface, I am making a static call. It is throwing exception as:
'Object reference not set to an instance of ..' (NULL REFERENCE EXCEPTION)

Need help..

Regards,
Rosh K M

Answers

  • JoeProJoePro CAUniversity ✭✭✭

    Can you tell us what your linker settings are in Release and in Debug mode? You will have to exclude the PCL from linking if your linker settings are set to Link All under release mode.

  • Xam_DeveloperXam_Developer INMember ✭✭
    edited August 2017

    The Linker behavior is set as Link Framework SDKs only. However, even if I give 'Link All' or 'Dont link', the behaviour is the same.

    My class lay out is as follows:

    ECN.iOs (Main.cs) ->
    ECN (All Xaml class) ->
    NManager(public static class, has declared Interface class (see Details 1 for more info) ) ->
    IOSNativeLib (Interface implementation, see Details 2 for more info )

    From XAML class (User Interface), I am calling record as follows:
    //Code
    public void OnButtonClick(object sender, EventArgs evtArgs)
    {
    try
    {
    bool ret = NManagerOps.RecordManager.StartRecord();

                --In Debug mode, it proceeds further without any null reference exception
            }
            catch(Exception oEx)
            {
                --In Release mode it comes here as Null Reference exception.
            }
        }
    

    //Code Ends

    Details 1:
    //Code
    public static class NManagerOps
    {
    public static IRecord RecordManager(get;} = DependencyService.Get<IRecordManager>();
    }
    //Code Ends

    Details 2:
    //Code
    class IOSRecLib : IRecord
    {
    public bool StartRecord()
    {
    }
    }
    //Code Ends

  • Xam_DeveloperXam_Developer INMember ✭✭

    Can you tell us what your linker settings are in Release and in Debug mode?
    I have set the 'Linker Behavior' as Link Framework SDKs Only'. However even if I give as 'Dont Link' or 'Link All' the call works only in Debug mode.

    Following is the class layout:

    ECN.iOS (Main.cs) ->
    ECN (All XAML class resides here ) ->
    NOps (Interface declaration. See Details 1 for more info) ->
    iOSNativeLib ( Interface method implementation. See Details 2 for more info)

    Following is the code where I get exception in release mode

    ECN:
    public void OnButtonClick(object sender, EventArgs evtArgs)
    {
    try
    {
    bool ret = NOps.RecordMgr.StartRecord();
    //In Debug mode, it starts successfully.
    }
    catch(CException oEx)
    {
    //In Release build, I get Null Exception here
    }
    }

    Details 1:
    public static class NOps
    {
    public static IRecordMgr RecordMgr{get;}= DependencyService.Get<IRecordMgr>();
    }
    public interface IRecordMgr
    {
    bool StartRecord();
    }

    Details 2:
    class IOSRecordMgr : IRecordMgr
    {
    public bool StartRecord()
    {
    return true;
    }
    }

  • Xam_DeveloperXam_Developer INMember ✭✭

    Can you tell us what your linker settings are in Release and in Debug mode?
    I have set the 'Linker Behavior' as Link Framework SDKs Only'. However even if I give as 'Dont Link' or 'Link All' the call works only in Debug mode.

    Following is the class layout:

    ECN.iOS (Main.cs) ->
    ECN (All XAML class resides here ) ->
    NOps (Interface declaration. See Details 1 for more info) ->
    iOSNativeLib ( Interface method implementation. See Details 2 for more info)

  • Xam_DeveloperXam_Developer INMember ✭✭
    edited August 2017

    Following is the code where I get exception in release mode

    ECN:
    public void OnButtonClick(object sender, EventArgs evtArgs)
    {
    try
    {
    bool ret = NOps.RecordMgr.StartRecord();
    //In Debug mode, it starts successfully.
    }
    catch(CException oEx)
    {
    //In Release build, I get Null Exception here
    }
    }

    Details 1:
    public static class NOps
    {
    public static IRecordMgr RecordMgr{get;}= DependencyService.Get<IRecordMgr>();
    }
    public interface IRecordMgr
    {
    bool StartRecord();
    }

    Details 2:
    class IOSRecordMgr : IRecordMgr
    {
    public bool StartRecord()
    {
    return true;
    }
    }

Sign In or Register to comment.