My product has a helper executable to uninstall all related sub-products. I uninstall based on upgrade codes of all sub-products.
First, I fetch the product code from upgrade code using MsiEnumRelatedProducts function. Then I try to uninstall the product using MsiConfigureProductEx function.
The problem is MsiConfigureProductEx is returning error.
Invoked Function: MsiConfigureProductsEx
Return Code: 1605 (0x00000645)
Description: This action is only valid for products that are currently installed.
Why is MsiEnumRelatedProducts returning a invalid product code ? I searched through the windows registry to see if such product code exists. There isn't any. How to debug the issue ?
Edit: Added minimum code that reproduces issue.
// UpgradeCodes is an array having upgrade codes of all modules.
TCHAR lpProductCode[GUID_STR_LENGTH];
const TCHAR tszNoReboot[] = _T("REMOVE=ALL REBOOT=ReallySuppress DISABLE_REBOOT_PROMPT=1");
for (size_t i = 0; i < sizeof(UpgradeCodes) / sizeof(UpgradeCodes[0]); i++)
{
tstring tstrUpgradeCode = UpgradeCodes[i];
DWORD dwIndex = 0;
size_t status;
// for each of the upgrade code, get all the products
do
{
status = MsiEnumRelatedProducts(UpgradeCodes[i],
0,
dwIndex,
lpProductCode);
if (ERROR_SUCCESS == status)
{
UINT uiReturn = MsiConfigureProductEx(lpProductCode,
INSTALLLEVEL_DEFAULT,
INSTALLSTATE_DEFAULT,
tszNoReboot);
if (ERROR_SUCCESS_REBOOT_REQUIRED == uiReturn)
{
// prompt for reboot at the end of all modules uninstallation.
}
if (ERROR_SUCCESS != uiReturn)
{
// log message with return code.
// Error Code: 1605 is coming from here.
}
}
}while (ERROR_NO_MORE_ITEMS != status);
}
Some years have passed and I want to add two scipts that can be used
to export MSI package information:
How can I find the product GUID of an installed MSI setup? - in section 2.
Do visit the link above, but here are direct links to the scripts:
1) the html export version and 2) the simpler text output.
Disclaimer: The below information is very "under the hood". Please use API calls whenever you can to access the MSI database. Also remember to run all your MSI testing on virtual machines so you can easily revert to a "clean state". During MSI development strange things can happen.
It is possible that a previous uninstall of that product of yours left something registered upon uninstall, and this is causing all the problems. I would try to check with scripts what is registered on the system.
Found good discussions of retrieving product info with VBScript here, a couple of really good scripts - recommended. Go to the sites to find the scripts, they format pretty poorly here and clog the answer.
http://forum.installsite.net/index.php?act=ST&f=26&t=14035
http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/
The Windows Installer database is mostly located here:
HKEY_CLASSES_ROOT\Installer\
The upgrade code section: HKEY_CLASSES_ROOT\Installer\UpgradeCodes
You must never touch anything in the Windows Installer Database Registry directly. It's extremely interconnected and easy to corrupt. Only go through the APIs. Note that the GUIDs in the registry are packed, so you won't find the GUIDs from the package in the registry.
Packed GUID: 03B1692A57845354EA63AD602436AB05
Regular GUID: {A2961B30-4875-4535-AE36-DA064263BA50}
Using the VBScripts above and the registry data directly for inspection you should be able to determine what is happening in the Windows Installer database.
I would never work straight in C++ to test this out. Instead I would eliminate some complexity by trying PowerShell or VBScript to determine what is wrong with the uninstall routine. You can find information on how to use these scripting tools here in this thread. And here is another thread.
It is not quite clear if some of the uninstalls work, and there is
one that fails or if the uninstall operation fails altogether? That's
the first question.
Have you tried manually uninstalling all products from add/remove to ensure they all uninstall correctly manually? One of the products could trigger an error return code during uninstall that is caught programatically, but is ignored during manual install. Often these can be from Custom Actions placed after InstallFinalize. In this case some setup redesign is called for. In the simplest case it would involve disabling error checking for the custom action, but that fix is not good enough in my opinion.
It is possible that the product is
installed, but per-user. In other words it might be installed only
for a single user on the machine, and not for the machine (this is controlled by the ALLUSERS property). I am not sure how this function works if this is the case - it may even report the product as advertised (available for on demand install via a shortcut, but not actually installed). Again, I have not tried this, and uninstall may still work. Just off the top of my head to try and give you some pointers.
Have you performed any major upgrades of existing MSI files as part of the install of your product?
One further question: are you running on Windows 8? And are these MSI files generated with WIX or some other tool? There have been some intermittent reports on problems that appear at least remotely similar.
If you have a package installer (like Microsoft SQL Server), it can install a host of other items during its installation phase.
Later, when you go to uninstall the big package installer, all of the items that installer added to the system should theoretically be removed.
So, try just uninstalling your application, stop, then look to see if the other smaller applications are still on the system.
If they are, then you will need to uninstall these individual applications first when your custom uninstall script starts.
I assume you already have a System.Configuration.Install.Installer class. Follow a set of steps when installing your application (1, 2, 3, etc.), then perform these steps in reverse order when uninstalling your application (3, 2, 1).
Trying a new approach for you. I have located two products that seem to have at least two productcodes registered for their upgrade codes. They are: MSVC redistributable 2008 and MSXML 4.0 SP2. I have written a small C++ test that seems to work ok.
Essentially I think you need to check for ERROR_NO_MORE_ITEMS before the next iteration of the loop so you don't try to uninstall products that are no longer installed.
Here is some VS2013 code that should compile out of the box on a fresh install, empty project.
UPDATE: updated code to use VS2017 and a minimal console application.
Create a new console project: File => New => Project... => Visual C++, Windows Desktop, Windows Console Application
Paste the below code into the main CPP file (replacing whatever is there)
Set a breakpoint and build & run (F5)
F10 to step through
If "Microsoft Visual C++ 2008 Redistributable" isn't installed, no related product codes will be found.
#pragma once
#include "stdafx.h"
// The below should really be in stdafx.h (precompiled header)
#define WIN32_LEAN_AND_MEAN // Exclude stuff from Windows.h
#define STRICT
#include <windows.h>
#include <msi.h>
#pragma comment(lib, "msi.lib") // To make code link
int main()
{
UINT i = 0;
UINT status = ERROR_SUCCESS;
TCHAR productcode[39] = {};
const TCHAR upgradecode[39] = L"{AA783A14-A7A3-3D33-95F0-9A351D530011}"; //Microsoft Visual C++ 2008 Redistributable
//const TCHAR upgradecode[39] = L"{7CE723E3-E56B-432C-9F24-78C0606045A5}"; // MSXML 4.0 SP2 (KB973688)
do
{
// look up (related) product code(s) for specified upgrade code
status = MsiEnumRelatedProducts(upgradecode, 0, i, productcode);
if (status == ERROR_NO_MORE_ITEMS) // Test here. 259, ERROR_NO_MORE_ITEMS
{
// No more productcodes for specified upgrade code
MessageBox(NULL, L"No more productcodes", L"Done", MB_OK);
break; // exit do-while loop
}
i++; // Next product code
MessageBox(NULL, productcode, L"Product Code:", MB_OK);
} while (status != ERROR_NO_MORE_ITEMS);
return 0;
}
There could be erronously registered products on your system due to failed major upgrades or similar advanced error scenarios, so I am not sure if this solves your problem.
Keep in mind that the Windows Installer Database at HKEY_CLASSES_ROOT\Installer\UpgradeCodes contains packed GUIDs. You can try the VBScript code found in the following link to convert back and forth between packed and regular GUID formats: http://www.symantec.com/connect/blogs/guid-converter
More info on guid formats here if it is interesting: http://www.symantec.com/connect/articles/working-darwin-descriptors
// TEST DATA 2014 (guids in different formats):
// UpgradeCode
// 41A387AA3A7A33D3590FA953D1350011 => {AA783A14-A7A3-3D33-95F0-9A351D530011}
//
// ProductCode
//
// Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
// CFD2C1F142D260E3CB8B271543DA9F98 => {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
//
// Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17
// D20352A90C039D93DBF6126ECE614057 => {9A25302D-30C0-39D9-BD6F-21E6EC160475}
// UpgradeCode
// 3E327EC7B65EC234F942870C0606545A => {7CE723E3-E56B-432C-9F24-78C0606045A5}
//
// ProductCode
//
// MSXML 4.0 SP2 (KB973688)
// 6E8A266FCD4F2A1409E1C8110F44DBCE => {F662A8E6-F4DC-41A2-901E-8C11F044BDEC}
// MSXML 4.0 SP2 (KB954430)
// DDA39468D428E8B4DB27C8D5DC5CA217 => {86493ADD-824D-4B8E-BD72-8C5DCDC52A71}
Related
I am trying to reproduce a WinML tutorial described in https://learn.microsoft.com/en-us/windows/ai/windows-ml/get-started-desktop and need help in resolving the "Access violation reading location" error while loading the model.
Installed Visual studio 2017, Windows 10, build version 17763 and followed the instructions in the tutorial.
Wondering if it could be due to access control issue, I tried placing the ONNX file in multiple locations, even inside the solution folder, tried on Debug x64 and x86 flavor, changed the file permission, but still does not work.
void LoadModel()
{
// load the model
printf("Loading modelfile '%ws' on the '%s' device\n", modelPath.c_str(), deviceName.c_str());
DWORD ticks = GetTickCount();
model = LearningModel::LoadFromFilePath(modelPath); //FAILS here.
ticks = GetTickCount() - ticks;
printf("model file loaded in %d ticks\n", ticks);
}
I expected the LearningModel::LoadFromFilePath(modelPath); to succeed and return a valid handle.
After further debugging, WINRT_RoGetActivationFactory in the below code returns REGDB_E_CLASSNOTREG Class not registered
namespace winrt
{
template <typename Interface = Windows::Foundation::IActivationFactory>
impl::com_ref<Interface> get_activation_factory(param::hstring const& name)
{
void* result{};
hresult hr = WINRT_RoGetActivationFactory(get_abi(name), guid_of<Interface>(), &result);
the error message "REGDB_E_CLASSNOTREG" isn't about the filename, it's about not being able to find the implementation of the LearningModel object. (if there were file issues, you'd get a file not found error or some other string.)
Please ensure that you have the right SDK (Windows SDK, build 17763 or later) and Windows OS version (Windows 10, version 1809 or later).
Recently installed new TS version into VS2013 and tried to use protected modifier.
However TS validator shows me an error (and underlines protected word with a red line.
I get an error like
Use of future reserver word.
; expected
looks like it's looking into old TS definitions.
Checked the project file and there is 1.1 version of TypeScript.
also running tsc -v produces 1.3.0.
Does somebody of you guys experience that?
What i'm missing and what to do to fix that.
Thank you a lot for any help.
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
thank you all guys. for your answers!
the reason was (oh, what's the shame =) ) the ReSharper.
It's validation was showing that error, suspending it i'm getting no errors now.
Looks like JetBrains guys should update their definitions like Web Essentials did.
As they aren't compatible with new TS version, 1.3. And no updates pending as for now.
Hope, it'll be useful for somebody else.
The answer to your question then is ReSharper 9.0 EAP.
It supports TypeScript 1.3 features: 'protected' modifier and tuples.
You're welcome to try it. Though, yes, it's a pre-release version, so overall stability is not strictly guaranteed.
Are you building from within Visual Studio, or from the command-line? What with different versions of the SDK being installed, as well as potentially the NPM package globally (if you've ever installed that), it can get quite messy as to which version gets picked up. For example, if I run 'where tsc' from the command prompt, I get the below hits (and this is without the 1.1 SDK on the path, though I am in the bin folder for testing the latest bits)
S:\src\TypeScript\bin>where tsc
S:\src\TypeScript\bin\tsc
S:\src\TypeScript\bin\tsc.js
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js
C:\Users\billti\AppData\Roaming\npm\tsc
C:\Users\billti\AppData\Roaming\npm\tsc.cmd
Can you verify via "where tsc" the locations and order you PATH is resolving the 'tsc' command?
That said, if you're building from within a VS project, it should locate the latest SDK via the build target. Does this also occur with a new TypeScript project (where the latest version and targets file should be referenced)?
Failing that, and I hate to say it... ready... did you try rebooting? :-) Sometimes updates to the PATH etc.. after an install don't get picked up until processes restart, and things like MSBuild can actually linger waiting for the next build as a perf optimization, rather than exit once the build is done (and thus may not pick up environment changes immediately).
It didn't work for me too. What I did to fix it was installing VS2013 Update 4 and after that, I executed the TypeScript 1.3 setup again and did a repair.
Also, you should make sure you don't have <TypeScriptToolsVersion>1.0</TypeScriptToolsVersion> in your csproject defined. Set it to 1.1 (not 1.3) or remove it entirely (then it will use the latest one). Hope that helps!
You can determine whether the issue is related to Visual Studio pointing at the wrong TypeScript version by following these steps.
Place this example code in C:\Temp\app.ts
interface Metadata {
something: string;
}
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
export class OtherClass extends SomeClass {
constructor() {
super();
this.metadata = null;
}
}
var x = new SomeClass();
// Not allowed
// x.metadata = null;
Run the command:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>tsc --module amd c:\Temp\app.ts
Taking care to ensure you are pointing at the 1.1 folder in the TypeScript SDK folder.
The output should be:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>
i.e. nothing, except you now have an app.js file.
You can also re-run the test after uncommenting the x.metadata = null; line - at which point you should get the error:
c:/Temp/app.ts(22,1): error TS2445: Property 'metadata' is protected and only accessible within class 'SomeClass' and its subclasses.
Next Steps...
If the above fails, please supply details of the problem.
The only real answer we could give though it remove it and check the 1.1 folder is gone before re-installing it by fetching the installer fresh from the Microsoft website (perhaps you have a bad installer or there was some problem during installation?) You may also want to check that you are on Visual Studio Update 4, as I am testing it on Update 4.
If the above worked as expected, your Visual Studio is not pointing at the correct version.
This could be because of the project file as Dick van den Brink has correctly mentioned. Check that you have <TypeScriptToolsVersion>1.1</TypeScriptToolsVersion> and that it is the only element with this name.
It can also be down to any Visual Studio extensions that may be messing with your TypeScript (for example, if you had a really old version of Web Essentials - in which case, update it - if it is some other extension, try disabling it).
Well, I've spent a day looking for solution and have read everything but I am not able to deploy my Qt application, so I decided to ask.
I'm using Qt 5.2.1 via the Visual Studio Add-In in VS 2013 Ultimate, the qt version is msvcr2012. I have the x86 version of Qt 5.2 (now the 3rd from the bottom at Qt Downloads page).
I'm targeting Win7 32-bit.
My OS is Windows7 64-bit, I'm building the app for win32, release /o2 (max speed) optimalization, /MD (dynamic C runtime), with libraries linked:
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib //this one is added by me, the others are automatically set with the Qt-AddIn template.
I build it, and to the release folder I put the followings:
EDIT: because of the version of my compiler, I also distribute the vs2012 dll.s as you see.
.../release /plugins /platforms
I've set the addittional library path with (just for the 100% chance of finding them):
void registerPluginsDir(QDir& exeDir)
{
QString pluginsRelPath = "plugins";
QString platformsRelPath = "platforms";
QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);
QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);
QStringList pathes = QCoreApplication::libraryPaths();
pathes << pluginsPath;
pathes << platformsPath;
QCoreApplication::setLibraryPaths(pathes);
for (auto i : pathes)
qDebug() << i << "\n";
};
int main(int argc, char *argv[])
{
QString exePath = QString::fromUtf8(argv[0]);
QFileInfo exeInfo(exePath);
QDir exeDir(exeInfo.absolutePath());
registerPluginsDir(exeDir);
QApplication a(argc, argv);
KeyGenerator w;
w.show();
return a.exec();
};
The pathes are correct. With the debugger I saw they were loaded from my app folder, not from the Qt main folder.
With depends.exe I checked everything. I only get 2 warnings, no errors:
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
I've copied the .dll-s according to the .dll-s loaded when debugged the app in Visual Studio. The only difference between depends.exe and the debug, that in VS system dll-s were loaded from SysWOW64, not system32.
With all these on my (developer) pc it runs withouth any error, but on the test (Win7 32-bit running on Microsoft Virtual PC) pc I get the 'infamous' error:
Failed to load platform plugin “windows”. Available platforms are:
(and here there are the full pathes to the .dll-s,
eg: D:\cproj\keygen\win32\Release\plugins\platforms\qwindows.dll, so it must have found them.
I followed this too: http://qt-project.org/wiki/Deploy_an_Application_on_Windows.
Renamed the Qt-dir, the console only output the release folder as library inputs (not the Qt-folders like my first test). It loaded the dll-s from the app folders, launched well. However, on my virtual PC, or on my brother's pac (Win7 32bit) it gives me the error.ˇA picture about this:
How to run it on 32-bit machine? I tried it with every build, release-win32, debug-win32, none of them works. I can't test it on more machines, on XP it can't even load the C-runtime, but that's not a target platform.
For more info please comment.
EDIT: Dependency walker on target pc shows the same as on dev pc. It still finds the plugins, but can't load.
I don't know why you bother with setting of the paths etc. The Qt wiki article that you link shows that you don't have a plugins folder, but everything from that folder should go into your executable's folder.
The advice they give is very simple:
Every .dll from Qt's bin directory needs to be copied to your executable's folder.
Everything (files and folders) from Qt's plugins and qml folders needs to be copied to your executable's folder.
You can then cut it down to modules that you don't use. Works for me, just fine.
It is also incorrect to say that "I have to add the .dll-s to the release build because I'm not using the commercial version.". If you follow my advice, you can easily build statically-linked executables with Qt 5 and MSVC 2012, I'm even giving details on how to target Windows XP with all that. And you can do it just fine under terms of LGPL, you just need to let your users relink your project (that doesn't imply giving out C++ sources!).
The problem was not with the plug-ins, but it also requested the VS2010 redists.
After I tried everything I've found it in the Qt folder, and tried running my app with installing it. Now it runs on the Virtual PC too, however, it was not listed (or I oversaw this) in the dependencies. It only listed 2012 and 2013 versions.
I've downloaded the WTL 8.0 package and come to find the scripts to install App Wizards don't support VS 2010.
Does anyone know of updates scripts to support installation in VS 2010?
Thank you!
The AppWizard for VS2010 above has two small glitches (however they might deter people from using WTL with VS2010). These are very easy to fix:
1) [Output Directory] and [Intermediate Directory] in new project properties are not followed by a backslash ('\').
To fix:
file: .\AppWiz\Files\Scripts\1033\default.js
I have replaced:
if(bDebug)
{
config.IntermediateDirectory = 'Debug';
config.OutputDirectory = 'Debug';
config.ATLMinimizesCRunTimeLibraryUsage = false;
}
else
{
config.IntermediateDirectory = 'Release\\';
config.OutputDirectory = 'Release\\';
config.ATLMinimizesCRunTimeLibraryUsage = true;
}
with
// Add generic configuration details
config.IntermediateDirectory = '$(SolutionDir)$(Configuration)\\';
config.OutputDirectory = '$(Configuration)\\';
config.ATLMinimizesCRunTimeLibraryUsage = !bDebug;
2) Some WTL headers are missing in newly created projects.
The symbol WTL_USE_CPP_FILES seems to be missing when the template stdafx.h file is parsed, as a result a bunch of header files are not included in new projects.
Again in .\AppWiz\Files\Scripts\1033\default.js, I have added:
// Add WTL_USE_CPP_FILES to all projects
wizard.AddSymbol("WTL_USE_CPP_FILES", true)
just below line 41 (so that the lines are always included). This seems to do the trick.
I've never looked at VS appWizards before (or js for that matter), so I can't guarantee the workarounds are concrete. It seems pretty straighforward though & I've been using WTL with VS2010 with no problems since I've made those changes...
WTL is awesome btw - many thanks to the folks who still maintain it!
Cheers,
Yiannis
WTL 8.0 was released in june 2007 so couldn't possibly support VS 2010.
You may download the current work in progress WTL 8.1 AppWizard from http://wtl.svn.sourceforge.net/viewvc/wtl/trunk/wtl/Wizards/AppWiz.tar.gz?view=tar and the matching library files from /include.tar.gz?view=tar.
After asking about what Visual Studio does to register a COM Library, it became clear that VS did two things for COM registration:
Registered the COM Library
Creates and registers a Type Library
Visual Studio seems to do this registration using regasm.exe. For the first part (the direct COM registration) using tallow or heat (WiX 2.0 or WiX 3.0) seems to get all of the basic COM registration information correct.
However, what tallow/heat doesn't seem to do is set up a type library installation. It would be possible to create a custom action to do this with a WiX installer and regasm.exe, but invoking custom actions are not best practices when it comes to Microsoft installer based installers.
Upon further research, it looks like an msi has the ability to generate the type library upon installation. In fact, WiX seems to have direct support for it! In a file element, you can add a Typelib element. In fact, an article over here on wix has an example of filling out the TypeLib element with Interface elements.
It seems there's at least two required attributes to an Interface element:
Id
Name
Larry Osterman speaks about the other parts of the interface that need to be registered for a TypeLib in general, and this Interface entry seems to take care of the individual parts. Larry says we need to specify the ProxyStubClassId32 as "{00020424-0000-0000-C000-000000000046}", so we can easily add that.
Where to go from there and what to fill out for the various Interface elements has me stumped. I've gone ahead and added the TypeLib element to my wix file, and it successfully compiles. I'm a bit clueless as to how to set up the Interface elements though. What do we need to do to properly fill out the TypeLib element, and what apps or tools can I use to get it?
The answer below by wcoenen looks promising...I'm going to give it a shot.
Update: Posted my final solution below as an answer.
Here's the lazy man's way of solving this problem: Use heat from WiX 3.0.
If you have a type library generated automatically and installed via regasm, heat can take the .tlb as an argument in
heat file c:\my\path\to\my.tlb -out tlb.wxs
It will generate all the typelib and interface elements you need to register. This won't solve the problem of needing to know them ahead of time, and it won't solve the problem of GUIDs changing when the version of the assembly changes (even if the interface doesn't - which is the only time you're supposed to change it) but it will get you partway there.
The following trick can help with harvesting any registry changes and turning them into a wxs file, including the typelib element you're after.
First, bring your registry back in a state where the type library was not registered:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe /tlb /u mylib.dll
Export this clean state of the registry to hklm-before.reg:
c:\WINDOWS\system32\reg.exe export HKLM hklm-before.reg
Register the type library again:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe /tlb mylib.dll
Export the new state of the registry to hklm-after.reg:
c:\WINDOWS\system32\reg.exe export HKLM hklm-after.reg
Now we have two text files, hklm-before.reg and hklm-after.reg. Create a diff.reg file which only holds the relevant differences between these. You can find the differences easily with a diffing tool. I like to use the diff tool included in TortoiseSVN since I already use that every day. (WinDiff doesn't seem to work well in this case because of text-encoding issues.)
We can now convert diff.reg into a .wxs by calling heat.exe with the reg command. (Requires wix 3.5 or newer.)
heat reg diff.reg -out typelib.wxs
It looks like to register a Type library, the best way would be to generate your own IDL or ODL file, which will contain your GUIDs. The Typelibs generated directly from the Assembly are [i]dependent[/i] on the assembly version numbers : the GUIDs are generated based on that information, even if the interface hasn't changed. Visual Studio uses regasm to register and generate the typelib. Underneath that, it uses RegisterTypeLib, a win32 call. Using the typelib element seems to do something similar. No good.
However! Creating the type library by hand is painful. It is possible to get those GUIDs another way: digging them out of the typelib and creating the elements yourself.
Larry Osterman has the information that's needed: there's certain registry keys that need to be set. You can do those with the Registry table (and in Wix3, that means RegistryValue elements.) The trick here is getting the GUIDs: any old GUID will not work. Normally, getting the GUIDs is simply a matter of looking in the IDL for your library (you wrote your own IDL, right? :) ).
If you didn't write an IDL or ODL file to compile into a typelib, they still exist, in the file. Microsoft provides several handy tools: LoadTypeLibEx and the ITypeLib interface. With these interfaces, you can browse the type library and get all sorts of information. How do we browse the library?
I simply took a look at how Regasm did it! A quick dissassemble later, and we find that regasm is written in C# too. Glory day. I started up a project, and with a few using statements and a PInvoke later, we have:
using System.Runtime.InteropServices; // for struct marshaling
using System.Runtime.InteropServices.ComTypes; // for the ITypeLib + related types
// TYPELIBATTR lives in two places: Interop and ComTypes, but the one
// in Interop is deprecated.
using TYPELIBATTR = System.Runtime.InteropServices.ComTypes.TYPELIBATTR;
/// <summary>
/// The registry kind enumeration for LoadTypeLibEx. This must be made
/// here, since it doesn't exist anywhere else in C# afaik. This is found
/// here: http://msdn.microsoft.com/en-us/library/ms221159.aspx
/// </summary>
enum REGKIND
{
REGKIND_DEFAULT,
REGKIND_REGISTER,
REGKIND_NONE
}
// and this is how we get the library.
[DllImport("oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false)]
private static extern void LoadTypeLibEx(string strTypeLibName, REGKIND regKind, out ITypeLib TypeLib);
Whew! Once we have this out, we have to navigate the structure. This is interacting with unmanaged resources, so get ready to be Marshaling stuff around.
ITypeLib lib = null;
LoadTypeLibEx(Value, REGKIND.REGKIND_NONE, out lib);
IntPtr libInfoPtr = IntPtr.Zero;
lib.GetLibAttr(out libInfoPtr);
TYPELIBATTR libInfo =
(TYPELIBATTR) Marshal.PtrToStructure(libInfoPtr, typeof(TYPELIBATTR));
int typeCount = lib.GetTypeInfoCount();
for (int i = 0; i < typeCount; ++i)
{
ITypeInfo info;
lib.GetTypeInfo(i, out info);
IntPtr typeDescrPtr = IntPtr.Zero;
info.GetTypeAttr(out typeDescrPtr);
TYPELIBATTR type =
(TYPELIBATTR)Marshal.PtrToStructure(typeDescrPtr, typeof(TYPELIBATTR));
// get GUID, other info from the specific type
}
lib.ReleaseTLibAttr(libInfoPtr);
libInfoPtr = IntPtr.Zero;
Whew. So, you have to write some code to extract the information. Once you do, you have to fill that information into Registy Entries, as specified By Larry Osterman.
Of course, you could avoid that step by simply writing your own IDL file to begin with. The choice in pain: it's up to you!