function in C# dll not found

Questions about MultiCharts and user contributed studies.
Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

function in C# dll not found

Postby Wally_AD » 27 Nov 2018

Hi,
I am trying to call functions in a C# dll.

Code: Select all

external method: "ClassLibrary1.dll", double, "SwissWrapper.Add", double, double;

..

value77 = SwissWrapper.Add(3.6, 7.2);
print ("Ret_My_lib ", value77);
C#File

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//using PowerLanguage;

//#import "c:\Program Files\TS Support\MultiCharts64\PLKit.dll" no_namespace;

namespace AstroLib
{
public class SwissWrapper
{
public static double Add(double x, double y)
{
return (x + y);
}

public static double Subtract(double x, double y)
{
return (x - y);
}

}
}
Using Multicharts.

When running the strategy MC rises the error message: Cannot find function " SwissWrapper.Add".

Can somebody help with the C# file.

Thanks
Urich

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: function in C# dll not found

Postby TJ » 27 Nov 2018

MC version? Build number?

Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

Re: function in C# dll not found

Postby Wally_AD » 28 Nov 2018

MultiCharts64 Version 11.0 Release (Build 15387)

wegi
Posts: 124
Joined: 02 Jun 2009
Has thanked: 5 times
Been thanked: 13 times

Re: function in C# dll not found

Postby wegi » 01 Dec 2018

Is it really possible to call a C# DLL from Multicharts?
I thought all DLL has to be native c++ dlls?

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: function in C# dll not found

Postby hughesfleming » 01 Dec 2018

It can be another language other than c++. It depends if the dll is managed or unmanaged. For C# you would need a wrapper.

Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

Re: function in C# dll not found

Postby Wally_AD » 01 Dec 2018

Right, C# does not work with Multicharts. Probably it will work with Multicharts.net, but I am not sure about this,
Using Visual Studio 2017 with a C++ compiler and C-syntax the following code works.

Code: Select all

#include "stdafx.h"

extern "C" {

__declspec(dllexport) double __cdecl Add(double x, double y)
{
double erg = 0.0;
erg = x + y;
return (erg);
}

__declspec(dllexport) double __cdecl Subtract(double x, double y)
{
return (x - y);
}

}
in PLE:

Code: Select all

DefineDLLFunc: "Dll1.dll", double, "Add", double, double;


Return to “MultiCharts”