Options

Problem using .NET object in NAV

leumass96leumass96 Member Posts: 9
edited 2017-07-25 in NAV Three Tier
Hello,

I try to use a .NET object in NAV but have a problem. With simple code, it works : I can instantiate a object, and call a method which gives back the string I gave to the constructor. But now I have a program in C# which communicates with MS Project. When I tried with a code that only connects and gives back the projects' list in a string I obtain an error message (see screenshots below). The program works when I use it in a .NET program.

I think it is caused by the genericity used by the Load<> method. Is it right ?

Has someone any idea of a solution ?

Thanks :smile:

EDIT the error message was the wrong one I just updated the screen shot.

n76fzaz7z4bw.png



as62ynoenz4j.png


2shy2dd81jhp.png


jt2w8zumtcee.png


n2mxnednch1w.png


a0gcnme0wftt.png

Answers

  • Options
    JuhlJuhl Member Posts: 724
    Open is just a function, so try to skip the first line and just call it. Send test parameter along with Open.
    Follow me on my blog juhl.blog
  • Options
    leumass96leumass96 Member Posts: 9
    Juhl wrote: »
    Open is just a function, so try to skip the first line and just call it. Send test parameter along with Open.

    Thank you very much for your answer but same thing append even without the first line. I tried and I should have remove this line before doing a screenshot.

    Thanks again
  • Options
    JuhlJuhl Member Posts: 724
    Long shot, try using string instead of String in parameter and return.

    Also make a hello world function without parameter and string as return type, just to cut away noise. This should work.

    What NAV version are you on?
    Follow me on my blog juhl.blog
  • Options
    leumass96leumass96 Member Posts: 9
    edited 2017-07-25
    Juhl wrote: »
    Long shot, try using string instead of String in parameter and return.

    Also make a hello world function without parameter and string as return type, just to cut away noise. This should work.

    What NAV version are you on?

    Thanks for your help, I just realize trying this that I post the wrong message.

    I obtain this message :

    jq8pryu9e4qe.png


    Have you an idea ?

    The method getA you can see below in my code works if I call it. So the Hello world works
  • Options
    JuhlJuhl Member Posts: 724
    You are using the integration wrong. It's not a NAV problem.

    Create a second program in VS and call your function from there, to test.
    I always use a simple console app to test, often easier to find errors in try catch in VS than in NAV
    Follow me on my blog juhl.blog
  • Options
    leumass96leumass96 Member Posts: 9
    Juhl wrote: »
    You are using the integration wrong. It's not a NAV problem.

    Create a second program in VS and call your function from there, to test.
    I always use a simple console app to test, often easier to find errors in try catch in VS than in NAV

    I tried this before and did it now again and it works :

    wm29r26x1f23.png
  • Options
    JuhlJuhl Member Posts: 724
    Then it should work.

    But I never use VS addons, it do it from c/al.
    Follow me on my blog juhl.blog
  • Options
    leumass96leumass96 Member Posts: 9
    Juhl wrote: »
    Then it should work.

    But I never use VS addons, it do it from c/al.

    Ok thanks.

    I think that the genericity isn't supported by NAV and C/AL. Don't you think it is possible ? because here the parameter of the Load method isn't T but I think NAV doesn't understand the generic type T and the implicit replacement. The method is defined as Load<T>(T arg) and I believe that C/AL doesn't understand that.

    But I know almost Nothing about NAV and C/AL so I can be wrong.

    I tried to write Load<"here the type of the argument"> but it doesn't work better.

    Thanks for your help

  • Options
    JuhlJuhl Member Posts: 724
    <T> is not directly supported, only if you create the class in c# and use it in c/al.
    But you only use string in and out, so it should be fine.
    Follow me on my blog juhl.blog
  • Options
    JuhlJuhl Member Posts: 724
    Could you be missing and assembly for projects in NAV service tier addin folder?
    Follow me on my blog juhl.blog
  • Options
    leumass96leumass96 Member Posts: 9
    Juhl wrote: »
    is not directly supported, only if you create the class in c# and use it in c/al.
    But you only use string in and out, so it should be fine.

    That what I thought too...
    Juhl wrote: »
    Could you be missing and assembly for projects in NAV service tier addin folder?

    I just looked and copy another time all the assemblies I have in the folder of the VS project in the add-in folder. Nothing new happened...
  • Options
    JuhlJuhl Member Posts: 724
    If two functions has the same in and output, and one works. Then it's not NAV unless an assembly is missing.
    Follow me on my blog juhl.blog
Sign In or Register to comment.