我有一个 DLL 文件。使用 DLL,我必须调用方法并在我的项目中添加更多方法。现在,我需要迁移旧的 DLL 以将该项目作为新的 DLL。我这样做了但问题是 C# 代码被转换为 net 模块它显示两个错误。我不清楚。请帮我解决它。
DLL 代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace mcMath
{
public class mcMathComp
{
    private bool bTest = false;
    public mcMathComp()
    {
        // TODO: Add constructor logic here
    }
    /// <summary>
    /// //This is a test method
    /// </summary>
    public void mcTestMethod()
    { }
    public long Add(long val1, long val2)
    {
        return val1 - val2;
    }
    /// <summary>
    /// //This is a test property
    /// </summary>
    public bool Extra
    {
        get
        {
            return bTest;
        }
        set
        {
            bTest = Extra;
        }
    }
}
}
CS项目:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mcMath;
namespace mcClient
 {
        class Program
        {
            static void Main(string[] args)
            {
                mcMathComp cls = new mcMathComp();
                long lRes = cls.Add(23, 40);
                cls.Extra = false;
                Console.WriteLine(lRes.ToString());
                Console.ReadKey();
            }
        }
    }
错误:
Program.cs(5,7):错误 CS0246:找不到类型或命名空间名称“mcMath”(您是否缺少 using 指令或程序集引用?)
试过的方法:
- 我将通过 Project-> Add Reference 添加引用。
- using Reference 也用到了。
- 将 DLL 放入当前项目的调试/发布文件夹