积极答复者
when i use reflection show Illegal characters in path.

问题
-
when i use reflection show Illegal characters in path.
My code follow this:
Assembly assembly = Assembly.LoadFrom(@"C:\Users\gaoja1\ Desktop\Reflection\Jack.Gao.Domain\bin\Debug\Jack.Gao.Domain.dll"); Type type = assembly.GetType("Jack.Gao.Domain.Person"); object o = Activator.CreateInstance(type); Type[] paramTypes = new Type[2]; paramTypes[0] = Type.GetType("System.String"); paramTypes[1] = Type.GetType("System.String"); MethodInfo methodInfo = type.GetMethod("Say", paramTypes); object[] paramMeters = new object[2]; paramMeters[0] = "Hello"; paramMeters[1] = ",World!"; object objRetval = methodInfo.Invoke(o, paramMeters); Console.WriteLine(objRetval); Console.ReadKey();
答案
-
你好, 不要将路径换行,换行后会有一个换行符在路径中,这个是非法字符, 你将两行代码写一行就好了.
Assembly assembly = Assembly.LoadFrom(@"C:\Users\gaoja1\Desktop\Reflection\Jack.Gao.Domain\bin\Debug\Jack.Gao.Domain.dll");
谢谢.
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Mike FengModerator 2012年8月3日 2:02
- 已标记为答案 Mike FengModerator 2012年8月9日 15:20
全部回复
-
请不要使用user,User文件夹恐怕无法直接访问。建议直接移动到D下或者其它一般盘符下试试看。
- 已建议为答案 Mike FengModerator 2012年8月1日 9:41
- 取消建议作为答案 Mike FengModerator 2012年8月1日 9:59
-
你好, 不要将路径换行,换行后会有一个换行符在路径中,这个是非法字符, 你将两行代码写一行就好了.
Assembly assembly = Assembly.LoadFrom(@"C:\Users\gaoja1\Desktop\Reflection\Jack.Gao.Domain\bin\Debug\Jack.Gao.Domain.dll");
谢谢.
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Mike FengModerator 2012年8月3日 2:02
- 已标记为答案 Mike FengModerator 2012年8月9日 15:20
-
你好!我已经解决这个问题了,应该用LoadFrom这个方法的。
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.