-
February 12th, 2014, 06:00 PM
#1
How to receive VBScript dictionary object and verify the data in C# Windows applicati
Hello Friends,
I am new to C# and would like to know is there any way to execute the VBScript function which return Dictionary object and want to receive the data into C# application.
Here is the my code and getting the error "Connot implicitly convert type 'object' to System.Collections.Generic.Dictionary<string, string>. An explicit conversion exists(are you missing a cast?)"
private void QCloginOK_Click(object sender, EventArgs e)
{
MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
sc.Language = "VBScript";
sc.AddCode(@"Function test
Set d = CreateObject (""Scripting.Dictionary"")
d (""Firstvalue"") = ""hello""
test = d
End Function");
object[] myParams = {};
Dictionary<string, string> sD = sc.Run("test", ref myParams);
}
Here I am using Microsoft Script control to execute VBScript functions.
Please can anyone guide me on this.
Thanks,
SG
-
February 12th, 2014, 11:14 PM
#2
Re: How to receive VBScript dictionary object and verify the data in C# Windows appli
This used to work with VB6:
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_HIDE As Long = 0
Private Sub command1_Click()
ShellExecute Me.hwnd, "Open", "C:\temp\capicom.vbs", vbNullString, "C:\vb\vb\", SW_SHOWNORMAL
End Sub
-
February 13th, 2014, 10:38 AM
#3
Re: How to receive VBScript dictionary object and verify the data in C# Windows appli
Thanks for your reply David
I can able to execute the VBScript functions using Microsoft Script Control in C# and if the return value is String then I can able to receive into C# code after execution, the problem is if it is dictionary object then I am getting the error at compilation itself. In my requirements we are giving an option to users to write there own code in VBScript and that will execute as an plug-ins and will display in my application as one of the tab. In plug-ins thy will write a code in vbscript and finally the code will collect the details and returns as a dictionary. So I would like to receive and handle it in C#.
-
February 13th, 2014, 08:01 PM
#4
Re: How to receive VBScript dictionary object and verify the data in C# Windows appli
that's a very bad idea. read up on SQL INJECTION for the same problem re-defined
-
February 14th, 2014, 01:55 AM
#5
Re: How to receive VBScript dictionary object and verify the data in C# Windows appli
Hi David,
Yes. You are correct. But here let me explain the situation of this project, actually I should not call as a project, it should call as a automation framework. Right now we have developed it completely in VBScripting. Now my team, managers and director made a decision to re-write the code in C# (only the framework). The framework will not be change for all the projects and each project may have a plug-in (this one particularly related to the projtoect) and those things we want to keep in VBScript (indivedual automation developers will develop this script and all of them are pertty much develop the script in vbscripting) and we don't want to change the existing plug-ins and these code will not be accessed by any regular users. So for now we are collecting all the details to re-write the things in c#.
Please can you help me if you know how to receive and access the data in c#.
And one more thing the VBScript code will in files and I will read and exetute using the Microsoft Script control.
Thanks,
SG
-
February 14th, 2014, 02:20 AM
#6
Re: How to receive VBScript dictionary object and verify the data in C# Windows appli
I'd switch everyone to POWERSHELL. That can be regulated a little easier than VBScript. Users can commit the changes, get them approved/accepted and then permitted to distribute to everyone.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|