Microsoft .NET Framework Interoperability : ERROR Constructo

Tharanga_ChandrasekaraTharanga_Chandrasekara Member Posts: 11
edited 2014-05-31 in NAV Three Tier
I have created a small .net class and build the project and following is the code. Actually this has nothing just a constructor that take a one string parameter ( I have tried this even without input parameter).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myDLLFile
{
    public class Class1
    {
        public Class1(string myString) 
        {
        
        }
    }
}

After that copied the .dll file to "C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\Add-ins" folder.
I have attached my DLL file and project file here.
http://www.sendspace.com/filegroup/g%2F ... BryQ9k8BKA

And then i created a codeunit and create a new variable myDLL type DotNet and selected my DLL file from the Dynamics NAV tab.
It shows my class and everything was perfect to that point.

Then i wrote my small one line of code in the run() of the code unit,
myDLL := myDLL.Class1('t');

it compile perfectly.
But when i run the code unit it throws the following error

Cannot create an instance of the following .NET Framework object: assembly myDLLFile, Version=1.0.0.0, Culture=neutral,PublicKeyToken=acf764e249539b6a, type myDLLFIle.Class1

I have tried so many options. But still error remains same.

Please give a small help to resolve this small issue.

Thank You.


Best regards,
Tharanga Chandrasekara.
For more info : NAV Community Blog |NAV General Blog]

Comments

  • lubostlubost Member Posts: 626
    Hi,

    NAV wants to call implicit constructor of desired class. Change your code to call MyDLL.Class1(); and assign myString as property.
  • I solve the issue. It was a small thing. In the .NET variable i just have to select RunOnClient : true


    Best regards,
    Tharanga Chandrasekara.
    For more info : NAV Community Blog |NAV General Blog]
  • kinekine Member Posts: 12,562
    You can run it on server too, but than you need to install the dll to the server too... ;-) of course, depends on what it should do. You cannot display windows etc. when running on server...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.