简体   繁体   中英

webservice with exceldna and c#

I am using a Java webservice. I'm consuming it with an Excel function which I made using c# and excel-dna. The problem is that everytime I call the function add I get (#valeur) .

This my c# code source:

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);
        }
    }
}

Service Reference has been included and the dna and xll files also.

Approach debugging this step by step. To debug an Excel DNA method from Visual Studio, you need to:

  • bring up your Excel; make sure that the XLL that is loaded is the one in the bin directory
  • in Visual studio "attach" to the excel process (tools->attach to process or Ctrl-Alt-p)
  • put a breakpoint at the start of your function (if the correct XLL is loaded the breakpoint will be a filled circle; if it isn't then the loaded XLL is a different one)

If you then make a call to your function and it doesn't hit the breakpoint, you may be passing in the wrong parameter types (side note: all numeric values in Excel are doubles - you can always have object parameters and check the arguments in your function).

If it does hit your function then you can step through your client code in the normal way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM