Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:04:42+00:00 2026-06-12T11:04:42+00:00

I have a problem with calling get_PrimaryKeys() function from msi.dll in c#. I want

  • 0

I have a problem with calling get_PrimaryKeys() function from msi.dll in c#.
I want to fund out what are the primary keys in a given MSI table. I use the following code:

Type installerType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
installer = (Installer)Activator.CreateInstance(installerType);
database = installer.OpenDatabase(MSIPath, MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);
WindowsInstaller.Record data = null;     
data = database.PrimaryKeys[tableName];
string s = data.get_StringData(1);

If I use database.get_PrimaryKeys(tableName), it gives the same error which is:

COMexception
Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

When I use other functions form msi.dll they works fine.

What is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:04:43+00:00Added an answer on June 12, 2026 at 11:04 am

    There’s an easier way to query MSI database from C# code. The WiX Toolset includes a well-designed convenient .NET API called DTF (Deployment Tools Foundation), which makes is possible to write the following (C#):

      using (var database = new Database("path\\to\\package.msi", DatabaseOpenMode.ReadOnly))
      {
        var table = database.Tables["someTableName"];
        foreach (var column in table.PrimaryKeys)
        {
          Console.WriteLine("The table {0} defines {1} as primary key", table.Name, column);
        }
      }
    

    All you have to do:

    • install WiX Toolset
    • reference Microsoft.Deployment.WindowsInstaller.dll in your C# project
    • add using Microsoft.Deployment.WindowsInstaller; namespace

    You don’t have to build your MSI with WiX in order to get advantage out of DTF. Reference DTF.chm (installed together with WiX) to know more about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem calling a JavaScript function in an iframe from the parent page.
I have a problem with calling the Match function from a VBA code: it
I have strange problem, with calling Lua function from C++. I have in Lua:
I have a problem with calling an overriden method from java class. I have
I have some problem with calling web service from flex. I have service with
I have got a problem with calling a global function, which takes a pointer
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have a problem returning/processing JSON data while calling $.get() function. Here's the code:
I have a problem calling a batch file from another batch file when trying
I'm calling the C# methods from a C++ unmanaged code. I have a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.