C# and Scriptlet

  • Thread starter Thread starter eddie
  • Start date Start date
E

eddie

Hi, my colleague wrote a scriptlet to get server wide environment variables
from ASP. However, my web application is written by C#, and I try to write a
program to access that COM but I always get a error. How can I solve this
problem? Any solution? Thanks!


An unhandled exception of type 'System.InvalidCastException' occurred in
mscorlib.dll
Additional information: QueryInterface for interface
ScriptletTypeLib.Automation failed.



ScriptletTypeLib.ASPEnvClass ASPEnv = new ScriptletTypeLib.ASPEnvClass();
Console.WriteLine(ASPEnv.GetItem().ToString());





<?XML version="1.0"?>
<package>
<?component error="true" debug="true"?>

<comment>
A script component to provide server wide environment variables
</comment>

<component id="ASPEnv">
<registration
progid="ASPEnv"
description="ASP Server-wdie Environment Variables"
version="1"
clsid="{BFCB53B7-6D17-4125-93BD-EB7FB18845F4}"/>

<public>
<method name="GetItem" />
</public>

<script language="VBScript">
<![CDATA[

Function GetItem()
GetItem = "hello"
End Function

]]>
</script>
</component>
</package>
 
Hi eddie
may be i didn't get your problem correctlly but , if the com component was
working fine then all what you have to do is .... Set the AspCompat
attribute of the Page directive "of your asp.net page"to true. and i hope
this solve the problem .....
 
Hi Mohamoss, thank you for your reply. In fact, I come from hp AsiaPacific
IT team, and now we manage several Web and DB servers. In order to manage
these staging and production servers well, my colleague wrote a scriptlet
for our ASP websites, so that our web developers can use the scriptlet to
query the Server Variables to know which server it is hosted and which DB to
use. However, some websites are written in C# by me, and I tried to call the
COM in global.asax but fails with the following error message. Can you give
me some hints about how to call this kind of COM (scriptlet) in my C#
program?

An unhandled exception of type 'System.InvalidCastException' occurred in
mscorlib.dll
Additional information: QueryInterface for interface
ScriptletTypeLib.Automation failed.

ScriptletTypeLib.ASPEnvClass ASPEnv = new ScriptletTypeLib.ASPEnvClass();
string ServerName = ASPEnv.Item("PROD_DB").ToString();





thanks,

eddie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top