V
Vamsi T via DotNetMonster.com
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.XPath.
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 ReflectionOnlyLoadFrom. 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.Reflection;
using System.Diagnostics;
using System.IO;
using System.Collections;
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\CompactFramework\2.0\WindowsCE\System.Xml.dll"};
assemblyPath = Path.GetDirectoryName(args[0]);
Assembly assembly = Assembly.ReflectionOnlyLoadFrom(args[0]);
AppDomain appDomain = AppDomain.CurrentDomain;
appDomain.ReflectionOnlyAssemblyResolve += new
ResolveEventHandler(appDomain_ReflectionOnlyAssemblyResolve);
Console.WriteLine("Loaded: " + assembly.FullName + "\
n========");
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
// Test System.Xml.XPath.XPathException's methods
if (type.FullName == "System.Xml.XPath.XPathException")
{
Console.WriteLine(type.FullName);
Console.WriteLine("\nMethodInfo\n=======\n");
foreach (MethodInfo methodInfo in type.GetMethods()
{
Console.WriteLine(methodInfo + ": " + attributes.
Length.ToString());
}
}
}
Console.WriteLine("\n=======");
}
catch (ReflectionTypeLoadException ex)
{
Console.WriteLine(ex.Message + "\n===");
}
}
static Assembly appDomain_ReflectionOnlyAssemblyResolve(object sender,
ResolveEventArgs args)
{
return Assembly.ReflectionOnlyLoadFrom(@assemblyPath + "\\" +
(args.Name.Substring(0, args.Name.IndexOf(','))) + ".dll");
}
}
}
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.XPath.
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 ReflectionOnlyLoadFrom. 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.Reflection;
using System.Diagnostics;
using System.IO;
using System.Collections;
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\CompactFramework\2.0\WindowsCE\System.Xml.dll"};
assemblyPath = Path.GetDirectoryName(args[0]);
Assembly assembly = Assembly.ReflectionOnlyLoadFrom(args[0]);
AppDomain appDomain = AppDomain.CurrentDomain;
appDomain.ReflectionOnlyAssemblyResolve += new
ResolveEventHandler(appDomain_ReflectionOnlyAssemblyResolve);
Console.WriteLine("Loaded: " + assembly.FullName + "\
n========");
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
// Test System.Xml.XPath.XPathException's methods
if (type.FullName == "System.Xml.XPath.XPathException")
{
Console.WriteLine(type.FullName);
Console.WriteLine("\nMethodInfo\n=======\n");
foreach (MethodInfo methodInfo in type.GetMethods()
{
Console.WriteLine(methodInfo + ": " + attributes.
Length.ToString());
}
}
}
Console.WriteLine("\n=======");
}
catch (ReflectionTypeLoadException ex)
{
Console.WriteLine(ex.Message + "\n===");
}
}
static Assembly appDomain_ReflectionOnlyAssemblyResolve(object sender,
ResolveEventArgs args)
{
return Assembly.ReflectionOnlyLoadFrom(@assemblyPath + "\\" +
(args.Name.Substring(0, args.Name.IndexOf(','))) + ".dll");
}
}
}