你能发现这个DLL的任何问题吗?

时间:2015-01-07 20:09:58

标签: c# dll reference

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EyesLib
{
    class Class1
    {

    public void drawEyes(int lookAtX, int lookAtY, int width, int height, Graphics eyeArea)
    {
        int xleft = 0, yleft = 0, xright = 0, yright = 0, xpleft = 0, ypleft = 0, xpright = 0, ypright = 0, reye = 0, rpupil = 0;
        xleft = width / 3;
        yleft = height / 2;
        xright = 2 * width / 3;
        yright = height / 2;
        reye = width / 9;
        rpupil = reye / 2;
        Bitmap bufl = new Bitmap(width, height);
        Graphics g = Graphics.FromImage(bufl);

        g.FillEllipse(Brushes.White, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
        g.FillEllipse(Brushes.White, xright - reye, yright - reye, 2 * reye, 2 * reye);
        g.DrawEllipse(Pens.Black, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
        g.DrawEllipse(Pens.Black, xright - reye, yright - reye, 2 * reye, 2 * reye);
        if ((lookAtX != xleft) || (lookAtY != yleft))
        {
            xpleft = (int)Math.Round(xleft + (reye - rpupil) / (Math.Sqrt(Math.Pow(lookAtX - xleft, 2) + Math.Pow(lookAtY - yleft, 2))) * (lookAtX - xleft));
            ypleft = (int)Math.Round(yleft + (reye - rpupil) / (Math.Sqrt(Math.Pow(lookAtX - xleft, 2) + Math.Pow(lookAtY - yleft, 2))) * (lookAtY - yleft));
        }
        else
        {
            xpleft = xleft;
            ypleft = yleft;
        }
        if ((lookAtX != xright) || (lookAtY != yright))
        {
            xpright = (int)Math.Round(xright + (reye - rpupil) / (Math.Sqrt(Math.Pow(lookAtX - xright, 2) + Math.Pow(lookAtY - yright, 2))) * (lookAtX - xright));
            ypright = (int)Math.Round(yright + (reye - rpupil) / (Math.Sqrt(Math.Pow(lookAtX - xright, 2) + Math.Pow(lookAtY - yright, 2))) * (lookAtY - yright));
        }
        else
        {
            xpright = xright;
            ypright = yright;
        }
        g.FillEllipse(Brushes.Black, xpleft - rpupil, ypleft - rpupil, 2 * rpupil, 2 * rpupil);
        g.FillEllipse(Brushes.Black, xpright - rpupil, ypright - rpupil, 2 * rpupil, 2 * rpupil);
        eyeArea.DrawImage(bufl, 0, 0);
        g.Dispose();



    }

    public void closeEyes(int width, int height, Graphics eyeArea)
    {
        int xleft = 0, yleft = 0, xright = 0, yright = 0, reye = 0, rpupil = 0;
        xleft = width / 3;
        yleft = height / 2;
        xright = 2 * width / 3;
        yright = height / 2;
        reye = width / 9;
        rpupil = reye / 2;
        eyeArea.FillEllipse(Brushes.Gray, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
        eyeArea.FillEllipse(Brushes.Gray, xright - reye, yright - reye, 2 * reye, 2 * reye);

    }
}
}

尽管构建正确,但引用时Visual Studio无法识别它。 它也不是.NET版本的问题。我尝试了所有4 / 4.5 /客户端配置文件等。我甚至重新设计了项目,我将DLL链接到了,但仍然存在问题。

1 个答案:

答案 0 :(得分:5)

是的。你的班级不公开。尝试将Class1公开,我感觉它会解决你的问题。

至于为什么,如果您没有明确提供访问修饰符,则类将默认为internal。由于您在外部程序集中引用了您的类,因此Intellisense无法帮助您找到它,因为外部调用程序实际上无法访问它。