By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

Getting intrinsic classic ASP object properties

P: n/a
I need to access classic ASP intrinsic objects and their properties from a
..net assembly wrapped to COM. The COM .net assembly is then instanciated from
a classic ASP page with Server.CreateObject().

I'm trying to use the Microsoft Transaction Server this way:

Type typeMtx = Type.GetTypeFromProgID("MTxAS.AppServer.1");
object mtxobject = Activator.CreateInstance(typeMtx);

// Getting classic ASP object context
object context = typeMtx.InvokeMember("GetObjectContext",
BindingFlags.InvokeMethod, null, mtxobject, null);

// Getting Request property
String strindex = "Request";
object myrequest = context.GetType().InvokeMember("Item",
BindingFlags.GetProperty, null, context, new object[] {strindex});

// Test: trying to get the TotalBytes property of Request. This seems
// to work, since something is returned ("0")
String totalbytes = myrequest.GetType().InvokeMember("TotalBytes",
BindingFlags.GetProperty, null, myrequest, new object[] { }).ToString();

// Getting the ServerVariables collection
object servervariables = myrequest.GetType().InvokeMember("ServerVariables" ,
BindingFlags.Default | BindingFlags.GetProperty, null, myrequest, new
object[] { });

// Getting the URL entry from ServerVariables
strindex = "URL";
object URLProp = servervariables.GetType().InvokeMember("Item",
BindingFlags.Default | BindingFlags.InvokeMethod, null, servervariables,
new object[] { strindex });

// Trying to read value
String url = typeURLProp.InvokeMember("Value",
BindingFlags.Default | BindingFlags.GetProperty, null, URLProp, new
object[] { });

When trying to read the "Value" of the "URL" ServerVariables entry, I get
this error:

HRESULT 0x80020006 (DISP_E_UNKNOWNNAME)

I've been trying to sort this out for one day, it seems all perfectly
logical to me, what am I doing wrong?

Fabrizio

Jul 2 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.