Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VbScript to automate a C# app?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,25324
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VbScript to automate a C# app?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 VbScript to automate a C# app? - 8/28/2005 11:26:16 AM   
  adammil2000

 

Posts: 2
Score: 0
Joined: 8/28/2005
Status: offline
Hi all,

I am trying to create a VBScript to automate a C# app I wrote. I simplified this code below to illustrate the problem.

The problem is when I run my VbScript, I get the error: "ActiveX component can't create
object: 'getobject'. Error 800A01AD". Any ideas what I did wrong?

Here's my VBScript:
dim o
set o=getobject(,"ConsoleApplication2.Program")
msgbox o.TestString

And here's my C# application that's running when I try to access it from
VbScript:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
public class Program
{
public string TestString = "testing 123";
static void Main(string[] args)
{
Console.ReadLine();
}
}
}

_____________________________

Adam Miller
http://www.tigermud.com
What kind of world would you create?
TigerMUD's goal is to let anyone create multiplayer text-based games using our feature-rich C# game engine.
 
 
Post #: 1
 
 RE: VbScript to automate a C# app? - 8/28/2005 7:01:13 PM   
  adammil2000

 

Posts: 2
Score: 0
Joined: 8/28/2005
Status: offline
I now have it working, partially. 

I can use CreateObject and create and then control the new instance of the C# code with VBScript. However, I cannot use an already running instance of the C# code using GetObject.  

What I am trying to do is the same as when you control an instance of MS Word with VBScript using GetObject(,"Word.Application"). This command doesn't actually start Word, but instead uses the instance that's already open and running. 

What I changed to get it working this far was to use the System.Runtime.InteropServices namspace, the [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] and [ClassInterface(ClassInterfaceType.None)] tags, and created a new interface with the same name as the class and that begins with an underscore (class interface) and did the regasm /tlb option. 

This is the last obstacle for me and I assume I am still doing something wrong. 

Thanks in advance for any ideas. 

_____________________________

Adam Miller
http://www.tigermud.com
What kind of world would you create?
TigerMUD's goal is to let anyone create multiplayer text-based games using our feature-rich C# game engine.

(in reply to adammil2000)
 
 
Post #: 2
 
 RE: VbScript to automate a C# app? - 8/29/2005 4:23:58 AM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
An excellent - and free - book about your problem is

  COM and .NET Interoperability
  by ANDREW TROELSEN

I found it at

   http://www.apress.com/free/

(in reply to adammil2000)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VbScript to automate a C# app? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts