osdir.com
mailing list archive

Subject: Calling object constructor from C - msg#00063

List: gnome.mono.devel

Date: Prev Next Index Thread: Prev Next Index
So I figured out the array problem I posted about earlier, but here's another
problem I'd like some help with.

I'm trying to call a constructor for an object from C using the following:

MonoDomain *domain = mono_domain_get();
MonoAssembly *assembly = (MonoAssembly *)mono_assembly_get_main();
MonoClass *na_class = mono_class_from_name(assembly->image,
"DOL", "NetworkAdapter");
MonoObject *na_this = mono_object_new(domain, na_class);
MonoMethod *na_ctor = NULL;
MonoString *test_string = mono_string_new(domain, "Test String");
MonoString *test_string2 = mono_string_new(domain, "Test String");
MonoString *test_string3 = mono_string_new(domain, "Test String");
MonoString *test_string4 = mono_string_new(domain, "Test String");
MonoString *test_string5 = mono_string_new(domain, "Test String");
MonoArray *ip_array, *subnet_array;
MonoObject *na;
const char *na_ctor_name = "DOL.NetworkAdapter:.ctor
(string,string[],string[],string,string)";
int i,;
void **args = g_new( void *, 5);

for (i = 0; i < na_class->method.count; i++) {
if (strncmp((char *)mono_method_full_name(na_class->methods[i]),
na_ctor_name, strlen(na_ctor_name)) == 0) {
na_ctor = na_class->methods[i];
break;
}
}

ip_array = mono_array_new(domain, mono_defaults.string_class, 1);
mono_array_set(ip_array, gpointer, 0, test_string);
subnet_array = mono_array_new(domain, mono_defaults.string_class, 1);
mono_array_set(subnet_array, gpointer, 0, test_string2);

args[0] = test_string3;
args[1] = ip_array;
args[2] = subnet_array;
args[3] = test_string4;
args[4] = test_string5;

na = mono_runtime_invoke(na_ctor, na_this, args, NULL);

The ctor is found ok, the arrays get set up ok, but mono_runtime_invoke always
returns null.
Any help?
Thanks.

--
James Lamanna
Applied Minds, Inc.
1209 Grand Central Ave.
Glendale, CA 91201
(818) 332-5214


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Virtual hosts with mod_mono_server

Is it possible to run multiple ASP.NET applications with mod_mono when apache is configured for name-based virtual hosts? The applications are to be located the vhost root. http://sitea.net/index.aspx http://siteb.net/index.aspx Do I need multiple mod_mono_server.exe's? Jarek

Next Message by Date: click to view message preview

[PATCH] Virtual hosts with mod_mono_server

Answering to myself: I've made some research and looks like virtual hosts can be implemented entirely on the "mod_mono_server" level. I've attached a patch that does this. Basically it extends the application specification so that you can include your vhost parameters. "hostname:port:vpath:directory" I've completely rewritten "GetApplicationForPath()" method: 1. I've replaced the hashtable lookup with a linear scan of an array (in most cases you have only a small number of applications and the performance of hashtable is poor in this case). For larger installations (e.g. hosting providers) it may be useful to do something more advanced (hashing or binary search) so that the method scales better, but I'm not sure if it's worth it. 2. I've eliminated all allocations from this method (there were actually a lot of them in String.Join() and String.Split()). Instead of splitting and re-joining strings I'm simply looking for an entry with the longest matching prefix. This is easily done with StartsWith() which afaik doesn't allocate anything. 3. My patch allows two "vpaths" to point to a single physical directory and run two different applicationhosts there. 4. There are some TODOs - basically related to retrieving information from the HTTP headers (port and host) but I don't have time and knowledge to dig into it as it looks to be apache-dependent. Can someone verify the patch, fix the TODOs and commit if it's ok? I've got only anoncvs access and this patch was made against today's fresh copy. Jarek ----- Original Message ----- From: "Jaroslaw Kowalski" <jaak@xxxxxxxxx> To: "mono-devel mailing list" <mono-devel-list@xxxxxxxxxxxxxxxx> Sent: Thursday, February 05, 2004 10:01 PM Subject: [Mono-devel-list] Virtual hosts with mod_mono_server > Is it possible to run multiple ASP.NET applications with mod_mono when > apache is configured for name-based virtual hosts? The applications are to > be located the vhost root. > > http://sitea.net/index.aspx > http://siteb.net/index.aspx > > Do I need multiple mod_mono_server.exe's? > > Jarek > > _______________________________________________ > Mono-devel-list mailing list > Mono-devel-list@xxxxxxxxxxxxxxxx > http://lists.ximian.com/mailman/listinfo/mono-devel-list > vhosts.patch Description: Binary data

Previous Message by Thread: click to view message preview

Virtual hosts with mod_mono_server

Is it possible to run multiple ASP.NET applications with mod_mono when apache is configured for name-based virtual hosts? The applications are to be located the vhost root. http://sitea.net/index.aspx http://siteb.net/index.aspx Do I need multiple mod_mono_server.exe's? Jarek

Next Message by Thread: click to view message preview

bug in mcs: error CS8003: Constant type is not valid

public sealed class Test { public const string A = "A"; public const string B = "B"; public const string[] ALL = new string[] { A, B, }; private Test() {} } Compiles fine with csc, but mcs fails with: ~Test.cs(10) error CS8003: Constant type is not valid (only system types are allowed) Compilation failed: 1 error(s), 0 warnings BTW: do you want me to file a bug in bugzilla? - Urs
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by