473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C# and Scriptlet

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>
Nov 15 '05 #1
3 6360
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 .....
Nov 15 '05 #2
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 .....
Nov 15 '05 #3
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

"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:1w**************@cpmsftngxa07.phx.gbl...
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 .....

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Born | last post by:
Hi; I use following code in an ASP page to generate a GUID: <% dim obj Set obj = Server.CreateObject("Scriptlet.TypeLib") Response.Write(obj.guid) Set obj = nothing %>
0
by: Lim Chee H | last post by:
Hi All, I have an ASP calling a scriptlet. There is a method "Exec" which is using Server.Execute to run any ASP file/command. There rest of the methods are working fine.Somehow,...
2
by: Hats | last post by:
Hi, I've a site with no php, but ssi and scriptlets do work. I tried these tags. ++++++++++++++++++++++++++++++++++++++++++++++++++ <object type="text/x-scriptlet"...
2
by: ze colmeia | last post by:
Hi all... i'm having trouble trying to pass a field value from a Data Access Page to a Scriptlet. Om my DAP i have: Function returnId() Dim pId pId = formName.Id.value returnId = pId
8
by: abctech | last post by:
Hi All, I have a dynamic table in my web page which I'm creating in a jsp-scriptlet - <html> <body> <% out.write("<table>") ; // code to add rows dynamically to the table from my...
9
by: unlikeablePorpoise | last post by:
I would like to have an HTML dropdown list where each selection calls a method. The following code doesn't work, but it I hope it gives the idea of what I'm trying to do: <FORM NAME="frm">...
3
by: oaklander | last post by:
I have this scriptlet working in a JSP and was wondering how I can put it in a class file and call it in my JSP. <jsp:useBean id="pageinfo" class="mypackage.PageInfo" scope="session"/> ......
1
by: inf | last post by:
How can i use java script variable in java scriptlet
2
by: freedom9ner | last post by:
Hello, I'm investigating how HTML can be componentized and reusable. Remember Microsoft's SCRIPTLET object (TYPE="text/x-scriptlet")? I thought this was a great invention. But other browsers do not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.