473,781 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Calling MsiEnumProducts Ex from CSharp

I have a new installer that allows the same product to be installed
multiple times on the same machine. I also have a configuration
program in .NET 2.0 SP1. I would like the config program to be able to
display a list of installed instances for the user to be able to pick
which instance they would like to configure. I was hoping to do this
by calling MsiEnumProducts Ex passing in the product code of my
application. However, I receive the following error.

FatalExecutionE ngineError was detected
Message: The runtime has encountered a fatal error.
The address of the error was at 0x79e71bd7, on thread 0x16d4.
The error code is 0xc0000005.
This error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code.
Common sources of this bug include user marshaling errors for COM-
interop or PInvoke, which may corrupt the stack.

I guess I must be calling the API incorrectly so any help would be
appreciated. The relevant bits of CSharp code are:

private const string MSI_LIB = "msi";

[DllImport(MSI_L IB, CharSet = CharSet.Auto)]
extern static public MsiError MsiEnumProducts Ex(string product,
string
userSid,

MsiInstallConte xt context,
uint index,
out string
installedProduc tCode,
out
MsiInstallConte xt installedContex t,
out string
szSid,
out uint
pcchSid);

internal enum MsiInstallConte xt : int
{
FIRSTVISIBLE = 0,
NONE = 0,
USERMANAGED = 1,
USERUNMANAGED = 2,
MACHINE = 4,
ALL = (MsiInstallCont ext.USERMANAGED |
MsiInstallConte xt.USERUNMANAGE D | MsiInstallConte xt.MACHINE),
ALLUSERMANAGED= 8,
}
uint index = 0;
MsiError result = MsiError.Succes s;
string productCode = "{3ACF577E-E488-4DFD-925E-A5846EA35EAF}";
string installedProduc tCode = null;
MsiInstallConte xt installedContex t;
string sid = null;
uint sidSize = 0;

result = MsiInterop.MsiE numProductsEx(p roductCode,
null,

MsiInstallConte xt.MACHINE | MsiInstallConte xt.USERMANAGED |
MsiInstallConte xt.USERUNMANAGE D,
index,
out
installedProduc tCode,
out
installedContex t,
out sid,
out sidSize);

Thanks in advance,

Mike.
Nov 14 '08 #1
0 2097

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

Similar topics

3
1378
by: trialproduct2004 | last post by:
Hi all I am having problem at a time of handling threading. I am having application containing thread. In thread procedure i ma using recursive function. This recursive function is adding some entries in my temprary file. But when i called abort on thread it is not aborting that thread. After calling aborting still entries are getting inserted into temporary files. That means still recursive function is getting executed. Can some one...
2
3486
by: Pawan Aggarwal | last post by:
I'm having trouble with calling an exported function in a native DLL compiled with eMbedded Visual C++ in C# application in PocketPC 2002 OS. Problem Description follows: I have one exported function in the DLL: I am making an application for pocket Pc in C# using this DLL Function. whenever I execute this exe in Pocket pc it returns MissingMethod Exception.
6
10172
by: Dave R | last post by:
Hello group, I had a COM dll in VC 6.0 which my Perl 5.8 modules used to call. With the .Net invent I would like to wrap up my COM functionality into C#. I wanted to know how can my Perl modules call the C# exe? Thanks, Dave P.S : AFAIK, Perl is also interoperable with the .Net languages.
7
3306
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,
23
3286
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
12327
by: NOSPAM | last post by:
I have a question on calling parent class... What I want to do is: when calling the derived class, it automatically executes the parent's method, is it possible? // main code: Derived d = new Derived(); d.SomeMethod(); public class Base
3
2677
by: RC | last post by:
Hi, I have a dll written by vb6. AFunction(ByRef o as Variant) I want to use it in csharp by System.Reflection. Assembly asm = Assembly.LoadFrom("Lib.dll"); Type t = asm.GetTypes("Lib.CLib"); object o = Activator.CreateInstance(t);
3
1538
by: Scott Gunn | last post by:
Hello all I'm trying to use the scrollwindowex api however I have the same problem as this guy had. There is an answer here in the reply. I just need some help converting it to VB.Net >Thanks Peter, it works. I have another question for you. What does the >clip rectangle passed on the 5th argument does? > >Thanks
6
10630
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and output parameter. My questions are: a. Can I expose a function in my CSharp code and internally call a javascript function?? Is this a good idea?? b. Do we have any tool which can convert a javascript function into
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.