Jump to content
  • Advertisement
Sign in to follow this  
adammil2000

[.net] Error accessing C# app from VBScript

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I am experimenting with scripting a .NET Game using external VBScripts. However, 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(); } } }

Share this post


Link to post
Share on other sites
Advertisement
Your C# program needs to be registered for COM Interop in order to do what you are trying to do.

Why would you want to "script a .NET game" in this way? If you are interested in games built on top of scripting, and want to use .NET, there are some articles around on how to use C# as the scripting language for a game engine.

Share this post


Link to post
Share on other sites
Thanks for the info.

I want any script like Python, VbScript, Java, etc. to be able to control the game engine. .NET is not the core focus, it just happens to be that I like to write the core code in C#, then let other folks extend and control the engine with whatever script they want.

I personally wanted to start working with VBScript and go from there.

Share this post


Link to post
Share on other sites
One additional question: I searched the Web based on your feedback and found more info about regasm, but it seems to only want DLLs to register. My program has no DLLs, it's just an EXE. What would the process be to register it for COM interop?

Please pardon my ignorance here.

Thanks!

Share this post


Link to post
Share on other sites
Well, the obvious thing to do is split the application into an executable part and a dll...

Cheers

Share this post


Link to post
Share on other sites
I now have it working, partially.

I can use CreateObject and create and then control the new instance of the C# game engine with VBScript. However, I cannot use an already running instance of the game engine 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.

[Edited by - adammil2000 on August 29, 2005 2:31:23 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!