Hi,
I'm using .NET CF 2.0. I have a problem in retrieving the exact methods of a
Class in CF. When I do a type.GetMethods () (where type is System.Xml.XPat h.
XPathException for example), I get get_HelpLink (GetProperties also returns
HelpLink) which is not available in CF. I'm loading the exact System.Xml.dll
from the CF directory using ReflectionOnlyL oadFrom. So the dll being probed
is correct but the methods being returned are not the exact ones available.
Here's the code. Any help is very much appreciated. Urgent.
using System;
using System.Reflecti on;
using System.Diagnost ics;
using System.IO;
using System.Collecti ons;
using System.Text;
namespace DNVsCF
{
class Program
{
static string assemblyPath = string.Empty;
static void Main(string[] args)
{
try
{
// Hardcoding args for testing
args = new string[] {@"C:\Program Files\Microsoft Visual
Studio 8\SmartDevices\ SDK\CompactFram ework\2.0\Windo wsCE\System.Xml .dll"};
assemblyPath = Path.GetDirecto ryName(args[0]);
Assembly assembly = Assembly.Reflec tionOnlyLoadFro m(args[0]);
AppDomain appDomain = AppDomain.Curre ntDomain;
appDomain.Refle ctionOnlyAssemb lyResolve += new
ResolveEventHan dler(appDomain_ ReflectionOnlyA ssemblyResolve) ;
Console.WriteLi ne("Loaded: " + assembly.FullNa me + "\
n========");
Type[] types = assembly.GetTyp es();
foreach (Type type in types)
{
// Test System.Xml.XPat h.XPathExceptio n's methods
if (type.FullName == "System.Xml.XPa th.XPathExcepti on")
{
Console.WriteLi ne(type.FullNam e);
Console.WriteLi ne("\nMethodInf o\n=======\n");
foreach (MethodInfo methodInfo in type.GetMethods ()
{
Console.WriteLi ne(methodInfo);
}
}
}
Console.WriteLi ne("\n=======") ;
}
catch (ReflectionType LoadException ex)
{
Console.WriteLi ne(ex.Message + "\n===");
}
}
static Assembly appDomain_Refle ctionOnlyAssemb lyResolve(objec t sender,
ResolveEventArg s args)
{
return Assembly.Reflec tionOnlyLoadFro m(@assemblyPath + "\\" +
(args.Name.Subs tring(0, args.Name.Index Of(','))) + ".dll");
}
}
}
--
Message posted via DotNetMonster.c om
http://www.dotnetmonster.com/Uwe/For...sharp/200509/1