.net Com可见类不可用

时间:2014-07-09 17:00:00

标签: c# .net comvisible

我已经编写了一个库,需要为它创建一个Com-wrapper。 regasm说com库的注册是成功的,然后我将库添加到VBA引用,但方法和类不可用。

using System.Linq;
using System.Runtime.InteropServices;
using BetLib2.Entity;
using BetLib2.Sports.Soccer.Grabber;

namespace BetCom.ComLib
{
    [ComVisible(true)]
    public class Com_Odd
{
    public string Name { set; get; }
    public string Odd { set; get; }
}

[ComVisible(true)]
public class Com_Market
{
    public string Name { set; get; }
    public Com_Odd[] Odds { set; get; }
}

[ComVisible(true)]
public class Com_SoccerMatch_Line
{
    Com_Market[] Markets { set; get; }
}

[ComVisible(true)]
public class Com_SoccerMatch
{
    public string Name { set; get; }
    public string Time { set; get; }
    public string Score { set; get; }
}

[ComVisible(true)]
public class Com_Result_SoccerMatch
{
    public string Error { set; get; }
    public Com_SoccerMatch[] Matches { set; get; }
}

[Guid("E1605FBE-54E8-4F7F-B86F-1399859236F8")]
[ComVisible(true)]
public interface ICom_SoccerGrabber
{
    Com_Result_SoccerMatch GrabMatches();
}

[Guid("DABD1A76-402B-49E1-B701-DED980D48871"),
ClassInterface(ClassInterfaceType.None),
ComVisible(true),
ComSourceInterfaces(typeof(ICom_SoccerGrabber))] 
public class Com_SoccerGrabber : ICom_SoccerGrabber
{
    public Com_Result_SoccerMatch GrabMatches()
    {
        SoccerMatchesGrabber grabber = new SoccerMatchesGrabber();
        var gResult = grabber.GetAllEntities();
        Com_Result_SoccerMatch retVal = new Com_Result_SoccerMatch()
        {
            Error = gResult.Message
        };
        if (gResult.Result == ResultEnum.ResultOk && gResult.ResultsList != null)
        {
            retVal.Matches = gResult.ResultsList.Select(match => new Com_SoccerMatch()
            {
                Name = match.Name,
                Score = match.Score,
                Time = match.Time
            }).ToArray();
        }
        return retVal;
    }

}

}

我通过教程制作所有内容,但没有结果。

0 个答案:

没有答案