[Mono-list] GetMethodFromHandle and mod mono web service

Matthias Blondeel blondeel at hotmail.com
Wed Aug 1 13:30:10 EDT 2007


Hello,

I am getting a System.NotImplementedException when trying to invoke
GetMethodFromHandle through a Web Service. I know this method has only
recently been implemented and I therefore use the latest mono packages from
2007 07 06. The method works fine if I call it directly. I get the exception
only when trying to invoke the method through Web Service.

Here is the code of the method:

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Collections.Generic;

namespace WebService1
{
	/// <summary>
	/// Description résumée de Service1
	/// </summary>
	[WebService(Namespace = "http://tempuri.org/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[ToolboxItem(false)]
	public class Service1 : System.Web.Services.WebService
	{

		[WebMethod]
		public string HelloWorld()
		{
			return "Hello World";
		}

		[WebMethod]
		public string GetMethodFromHandle()
		{
			Console.WriteLine("Hello World!");

			TestClass<int> test = new TestClass<int>();

			RuntimeMethodHandle methodHandle =
test.GetType().GetProperty("MyList").GetGetMethod().MethodHandle;

			System.Reflection.MethodBase methodBase =
System.Reflection.MethodInfo.GetMethodFromHandle(methodHandle,
typeof(TestClass<int>).TypeHandle);

			List<int> list = (List<int>)methodBase.Invoke(test, null);

			return list.Count.ToString() ;
		}

	}

}

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace WebService1
{
	public class TestClass<T>
	{
		private List<T> _myList = new List<T>();

		public List<T> MyList
		{
			get
			{
				return _myList;
			}

		}

	}
}

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Here is my httpd.conf file from apache:
### Global Environment
######################################################
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests.

# run under this user/group id
Include /etc/apache2/uid.conf

# - how many server processes to start (server pool regulation)
# - usage of KeepAlive
Include /etc/apache2/server-tuning.conf

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog /var/log/apache2/error_log

# generated from APACHE_MODULES in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/loadmodule.conf

# IP addresses / ports to listen on
Include /etc/apache2/listen.conf

# predefined logging formats
Include /etc/apache2/mod_log_config.conf

# generated from global settings in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/global.conf

# optional mod_status, mod_info
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf

# optional cookie-based user tracking
# read the documentation before using it!!
Include /etc/apache2/mod_usertrack.conf

# configuration of server-generated directory listings
Include /etc/apache2/mod_autoindex-defaults.conf

# associate MIME types with filename extensions
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf

# set up (customizable) error responses
Include /etc/apache2/errors.conf

# global (server-wide) SSL configuration, that is not specific to 
# any virtual host
Include /etc/apache2/ssl-global.conf



# forbid access to the entire filesystem by default
<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

# List of resources to look for when the client requests a directory
#DirectoryIndex index.html index.html.var
DirectoryIndex Default.aspx index.html index.html.var

### 'Main' server configuration
#############################################
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
Include /etc/apache2/default-server.conf



# Another way to include your own files
#
# The file below is generated from /etc/sysconfig/apache2,
# include arbitrary files as named in APACHE_CONF_INCLUDE_FILES and
# APACHE_CONF_INCLUDE_DIRS
Include /etc/apache2/sysconfig.d/include.conf


### Virtual server configuration
############################################
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry
about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
Include /etc/apache2/vhosts.d/*.conf


# Note: instead of adding your own configuration here, consider 
#       adding it in your own file (/etc/apache2/httpd.conf.local)
#       putting its name into APACHE_CONF_INCLUDE_FILES in 
#       /etc/sysconfig/apache2 -- this will make system updates 
#       easier :) 

#Note: Config Section for asp.net web applications with mod-mono and apache

#***********************************************************
#WebService1
MonoServerPath default /usr/bin/mod-mono-server2

 LoadModule mono_module modules/mod_mono.so

   Alias /webservice1 "/srv/www/htdocs/WebService1/WebService1"
   AddMonoApplications default
"/webservice1:/srv/www/htdocs/WebService1/WebService1"
   <Location /webservice1>
       SetHandler mono
   </Location>

#************************************************************


<Location /mono>
  SetHandler mono-ctrl
  Order deny,allow
  Deny from all
  Allow from 192.168.1.70
 Allow from localhost
</Location>
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

And finally this is the error message I am receiving:

The remote server returned an error: (500) Internal Server Error.
System.NotImplementedException: The requested feature is not implemented.
  at System.Reflection.MethodBase.GetMethodFromHandle (RuntimeMethodHandle
handle,
        RuntimeTypeHandle declaringType) [0x00000] 
  at WebService1.Service1.GetMethodFromHandle () [0x00000] 
  at <0x00000> <unknown method>
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(object,object[])
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr,
        System.Reflection.Binder binder, System.Object[] parameters,
        System.Globalization.CultureInfo culture) [0x00000] 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
My mono compiler version is :
Mono JIT compiler version 20070706 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       normal
        Architecture:  x86
        Disabled:      none
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

I don't know how exactly mod mono works, but I'm guessing it's using the
compiler installed on my computer no? So I don't understand why I get the
exception, although through direct call it works.

Thanks for your help,
Matthias
-- 
View this message in context: http://www.nabble.com/GetMethodFromHandle-and-mod-mono-web-service-tf4201504.html#a11950149
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list