【问题标题】:webservice with exceldna and c#带有exceldna和c#的webservice
【发布时间】:2016-06-22 17:57:22
【问题描述】:

我正在使用 Java 网络服务。我正在使用我使用 c# 和 excel-dna 制作的 Excel 函数来使用它。问题是每次我调用函数 add 我都会得到(#valeur)。

这是我的 c# 代码源:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExcelDna.Integration;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace MyLibrary
{
    public class Class1
    {
        [ExcelFunction(Description = "adds two terms")]
        public static int add(int a, int b)
        {

            ServiceReference1.ServerImplClient client =
                new ServiceReference1.ServerImplClient();
            return client.addition(a, b);
        }
    }
}

已包含服务参考以及 dna 和 xll 文件。

【问题讨论】:

  • 将返回类型更改为'object',然后包装在try-catch块中,并返回异常详细信息。

标签: c# excel web-services excel-dna


【解决方案1】:

逐步调试此方法。 要从 Visual Studio 调试 Excel DNA 方法,您需要:

  • 打开您的 Excel;确保加载的 XLL 是 bin 目录中的那个
  • 在 Visual Studio 中“附加”到 excel 进程(工具->附加到进程或 Ctrl-Alt-p)
  • 在函数的开头放置一个断点(如果加载了正确的 XLL,断点将是一个实心圆圈;如果不是,则加载的 XLL 是不同的)

如果您随后调用您的函数并且它没有命中断点,则您可能传入了错误的参数类型(旁注:Excel 中的所有数值都是双精度值 - 您始终可以拥有对象参数并检查函数中的参数)。

如果它确实影响了您的功能,那么您可以以正常方式逐步执行您的客户端代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多