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