C#dll使用问题

时间:2014-08-03 19:09:12

标签: c# visual-studio-2012 dll

我遇到了从我编写的一段代码编译C#dll的问题。它编译得很好而没有错误,但是当我尝试将它包含到visual studio 2010 C#应用程序时,命名空间在尝试从“using”命令调用它时不会显示。 这是.dll文件的代码:

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

namespace PARKER_SCRIPT
{
    class PScript
    {
    //LOAD_REF




    private void loadCustomScripts()
    {

    }   

    //END_REF

    PADScript p = new PADScript();
    private void loadScripts()
    {

    }

    public PScript()
    {
    }

    public void runFile(string file)
    {
        if (file.ToLower().Contains(".pb"))
        {
            //file = file.Replace(".pb", "");
            p.executeLuaWithThread(file);
    Console.ReadLine();
        }
        else
        {
            Console.WriteLine("ERROR 1: must be .pb file");
            Console.ReadLine();
        }
    }
    Core cp = new Core();

    public PADScript loadScipt(PADScript l)
    {
        loadScripts();
        loadCustomScripts();
        l.addLuaCommand("runFile", this);
        return l;
    }

    //this will be dynamically be updated when custom cs code gets added
    private string[] getPatchNotes()
    {
        string[] info = null;

        try
        {
            info = System.IO.File.ReadAllLines("info\\patch_notes.txt");
            return info;
        }
        catch (Exception i)
        {
            Console.WriteLine(i.Message);
            return info;
        }

    }

    private string getVersion()
    {
        string info = null;

        try
        {
            info = System.IO.File.ReadAllLines("info\\version.txt")[0];
            return info;
        }
        catch (Exception i)
        {
            Console.WriteLine(i.Message);
            return info;
        }

    }

}
}

我不认为.dll文件中的函数是个问题,但是通过在命令行上编译它我觉得我错过了一个关键参数或其他东西。我知道当我在visual studio中编译它时,它可以很好地实现它到一个新项目。提前谢谢。

编辑:这是我做的命令行:

C:\WINDOWS\Microsoft.Net\Framework\v4.0.30319\csc.exe /out:Release\ParkerScript.dll /target:library /platform:x86 /reference:core\LuaInterface.dll /reference:core\System.Speech.dll /reference:core\PAD_SCRIPT.dll /reference:core\lua51.dll  core\Program_lib.cs core\AssemblyInfo.cs core\lib\*.cs

1 个答案:

答案 0 :(得分:1)

类定义是内部的,在引用时不会显示。

像这样定义你的类:

namespace PARKER_SCRIPT
{
    public class PScript
    {
        //Code goes here...
    }
}