从MBS Axapta 3访问COM DLL
我们公司有MBS Axapta 3。老板不想迁移到更高版本的Dynamics AX,所以我不得不这么做 基本上,我尝试的是从Axapta的X++代码访问我自己的COM DLL。我希望能够访问.net函数,因此我使用本教程创建了DLL: 我的DLL的最终代码是:从MBS Axapta 3访问COM DLL,dll,com,axapta,microsoft-dynamics,ax,Dll,Com,Axapta,Microsoft Dynamics,Ax,我们公司有MBS Axapta 3。老板不想迁移到更高版本的Dynamics AX,所以我不得不这么做 基本上,我尝试的是从Axapta的X++代码访问我自己的COM DLL。我希望能够访问.net函数,因此我使用本教程创建了DLL: 我的DLL的最终代码是: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Cl
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ClaseCOM
{
public class Test
{
[Guid("12D1EDAC-20C0-4faa-A774-B6F4C300B47E")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IMathCtrl
{
[DispId(1)]
int AddNumbers(int a, int b);
}
[Guid("282902B4-5FB9-461d-9CD0-FE8DD851F979")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SFTCSServer.MathCtrl")]
public class MathCtrl : IMathCtrl
{
public MathCtrl() { }
public int AddNumbers(int a, int b)
{
return (a + b);
}
public int MuliplyNumbers(int a, int b)
{
return (a * b);
}
}
public static string ReturnString(string a)
{
return "Ha enviado " + a;
}
}
}
生成tbl并向gacutil注册dll后,我可以从Axapta调用我的dll,但它无法识别任何方法。它给出了一个错误“方法不存在”
这是我的x++代码:
static void DT_PruebasCOM(Args _args)
{
COM PruebaCOM;
COMVariant a,b; ;
PruebaCOM = new COM('ClaseCOM.Test');
// create variants to hold the arguments for the functions
a = new COMVariant(COMVariantInOut::OUT, COMVariantType::VT_I4);
b = new COMVariant(COMVariantInOut::OUT, COMVariantType::VT_I4);
PruebaCOM.ReturnString();
}
对于AddNumbers、MathCtrl和IMathCtrl,它给出了相同的错误,因此我不知道是否需要设置一些东西,以便使这个方法在Axapta代码中可见
有没有办法解决这个问题
谢谢 您的progid ClaseCOM.Test与SFTCSServer.MathCtrlYou代码也与您的对象/方法不匹配,ReturnString不是接口的方法等。如果需要帮助,请更新您的答案。您的参数不应该存在,请检查