dll代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using ModuleBasemMethod;namespace StockMethod
{
public class Stock :ModuleBase
{ public string check(string str)
{
return "你传入的参数是:" + str;
} public string Nulls()
{ return "你调用的方法是无效的";
}
}
}
由于我引用了ModuleBasemMethod和继承了ModuleBase类所以造成type = ass.GetType("StockMethod.Stock",true,true)返回的错误提示是:
能加载文件或程序集“BaseMethod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
如果去掉引用和继承就正常~这个问题怎么解决?
using System;
using System.Collections.Generic;
using System.Text;
using ModuleBasemMethod;namespace StockMethod
{
public class Stock :ModuleBase
{ public string check(string str)
{
return "你传入的参数是:" + str;
} public string Nulls()
{ return "你调用的方法是无效的";
}
}
}
由于我引用了ModuleBasemMethod和继承了ModuleBase类所以造成type = ass.GetType("StockMethod.Stock",true,true)返回的错误提示是:
能加载文件或程序集“BaseMethod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
如果去掉引用和继承就正常~这个问题怎么解决?
不妨贴出来
System.Reflection.Assembly.LoadFile看看,肯定可以
项目中没有添加dll引用吧
System.Reflection.Assembly ass;
Type type ;
object obj;
try
{
ass = System.Reflection.Assembly.LoadFile(@"F:\Stock.dll");
type = ass.GetType("StockMethod.Stock",true,true);
.....略
}
catch (Exception ex)
{
Response.Write(ex + "<br>");
}
finally
{
ass = null;
type = null;
obj = null;
}
}
如果LZ使用的是Assembly的LoadFile方法,那么搂主不需要添加引用,但得传入程序集的完整路径,这个路径可以是绝对路径也可以是相对路径,但必须是完整的路径。