views:

240

answers:

3

Hi, I was reading the Platform SDK samples, and the examples are in VB.NET. I use C# so I was wondering, how can I replicate this line in C#?

Set   Installer   =   CreateObject("WindowsInstaller.Installer")

Thank you.

+1  A: 

That looks like VB6/VBScript, not VB.NET :) But I might be wrong.

Options are:

  1. Look for the .NET framework equivalent of the WindowsInstaller.Installer object and use that.
  2. Use Activator.CreateInstance(). But don't expect a strongly-typed response.
  3. Add a reference to the WindowsInstaller.Installer COM object and VS will generate a strongly-typed interop which will allow you to create an instance in C#.
OJ
+2  A: 
using System.Runtime.InteropServices;

Type InstallerType;
object Installer;

InstallerType= Type.GetTypeFromProgID("WindowsInstaller.Installer");
Installer= Activator.CreateInstance(InstallerType);
Otávio Décio
A: 

That's VBScript I think.

You'd be better off searching for whatever you're trying to do within the .NET framework. It has a rich installer library that should make it easy. Don't just try to use some COM object because that's what you found. Work in the framework you're in.

TheSoftwareJedi