首页 新闻 会员 周边

AX与.NET的互操作性

0
[待解决问题]

有哪位高手,能指点下,在x++里,去调用c#代码,该如何操作??比如说,我在在.NET下写了一个方法,我现在需要在x++里去调用这个方法。如下:

//c# code

 

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

namespace DotNetNamespace
{
    class DotNetClass
    {
       
        static public void CalledCSharp // Method.
        (
        int iLengthOfOldPrefix         // by value
        , string sWhole                 // by value
        , ref string sNewPrefixPlusName // by reference
        , out string sDiscardedPrefix   // by reference
        )
        {
            sNewPrefixPlusName = sNewPrefixPlusName
                + sWhole.Substring(iLengthOfOldPrefix);
            sDiscardedPrefix = sWhole.Substring
                (0, iLengthOfOldPrefix);

        }
}

 

//x++ code

static void JobByrefCallerXpp(Args _args)
{
    int iLengthOfOldPrefix;
    str sWhole;
    str sNewPrefix;

    str sNewPrefixPlusName
        ,sDiscardedPrefix;

    ;

    iLengthOfOldPrefix = 5; // 'Foods' is 5 characters.
    sWhole = "Foods: triangle, square, circle.";
    sNewPrefix = "Shapes";

    sNewPrefixPlusName = sNewPrefix;
    DotNetNamespace.DotNetClass::CalledCSharp
        (
        iLengthOfOldPrefix
        ,sWhole
        ,byref sNewPrefixPlusName
        ,byref sDiscardedPrefix
        );

    info("sNewPrefixPlusName = " + sNewPrefixPlusName);
    info("sDiscardedPrefix = " + sDiscardedPrefix);
}

 

 

这是我参考msdn里的代码。x++代码中"DotNetNamespace.DotNetClass::CalledCSharp"直接这样写不行,会报错,我想问是否是需要配置或者什么???望高手指点。

adingkui的主页 adingkui | 初学一级 | 园豆:200
提问于:2011-08-31 16:11
< >
分享
所有回答(1)
0

我的版本是4.0,我们是AX里面先将.NET的包添加应用到AOT\References下面。

然后就可以再代码里面使用了。

你可以参考一下。

szlailai | 园豆:202 (菜鸟二级) | 2013-07-23 18:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册