c# dll使用问题
本文关键字:问题 dll | 更新日期: 2023-09-27 18:16:16
我有一个问题,从我写的一段代码编译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
类定义是内部的,在引用它时不会显示。
这样定义你的类:
namespace PARKER_SCRIPT
{
public class PScript
{
//Code goes here...
}
}