反射的DLL中不能加载xml文件.为什么?

startray 2009-08-03 02:35:28
Assembly asm = Assembly.LoadFrom(Directory.GetCurrentDirectory() + "\\test.dll");

Type[] ts = asm.GetTypes();
foreach (Type t in ts)
{
if (t.IsClass)
{
if (t.Name == ClassName)
{
object obj = asm.CreateInstance(t.FullName);

MethodInfo mi = t.GetMethod("TestClassname", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(string) }, null);

List<T> st= (List<T>)mi.Invoke(obj, new object[] { TestStr });
}
}
}


test 类:

public string TestClassname( string TestStr)
{
XPathDocument doc = new XPathDocument(TestStr);
XPathNavigator nav = doc.CreateNavigator();

}

new一个xpathdocument对象时就报错,为什么呀?
Exception has been thrown by the target of an invocation.
targeinvocationexception was unhandled

怎么解决呀?
...全文
72 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
startray 2009-08-03
  • 打赏
  • 举报
回复
知道原因啦。。。谢谢各位
startray 2009-08-03
  • 打赏
  • 举报
回复
是一个xml文件路径,我把那个参数拷下来到运行里,一打就能出来。
startray 2009-08-03
  • 打赏
  • 举报
回复
参数正确。传进去的也对。
cpp2017 2009-08-03
  • 打赏
  • 举报
回复
这与反射没关系吧,
zgke 2009-08-03
  • 打赏
  • 举报
回复
参数 Uri TestStr 是否正确啊

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧