This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Automation interface and .NET
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 20, 2008
03:16 AM
Automation interface and .NET
[CODE]
// Visual C# 2.0
01: using ISWiAuto14; // IS2008
.....
02: ISWiProject prj = new ISWiProject();
03: if (prj.OpenProject("MyProject.ism", false) != 0)
04: return 0;
05: ISWiProductConfig cfg = prj.ISWiProductConfigs[1];
06: ISWiRelease rls = cfg.ISWiReleases[1];
07: rls.Build();
...
[/CODE]
At line 6 I receive exception ("exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)"), but this code worked correctly when I used IS12. :confused:
// Visual C# 2.0
01: using ISWiAuto14; // IS2008
.....
02: ISWiProject prj = new ISWiProject();
03: if (prj.OpenProject("MyProject.ism", false) != 0)
04: return 0;
05: ISWiProductConfig cfg = prj.ISWiProductConfigs[1];
06: ISWiRelease rls = cfg.ISWiReleases[1];
07: rls.Build();
...
[/CODE]
At line 6 I receive exception ("exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)"), but this code worked correctly when I used IS12. :confused:
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 20, 2008
10:45 AM
It sounds like you don't have a release at index 1; perhaps you are using a new project or cleaned out your releases? I would expect, in C#, that the array index to start at 0 so you might try that instead if you have at least one release. Alternately, explore something like a foreach (ISWiRelease rls in cfg.ISWiReleases) { rls.Build(); } (or possibly a debugging message) to verify you are accessing releases in your project?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 21, 2008
03:13 AM
1. No, I have a release at index 1.
2. cfg.ISWiReleases is not array; InstallShield automation interface indeces is 1-based (and I have 2 releases 🙂 );
3. "foreach" don't work too, for example:
or
Maybe it's Macrovisions error.:(
2. cfg.ISWiReleases is not array; InstallShield automation interface indeces is 1-based (and I have 2 releases 🙂 );
3. "foreach" don't work too, for example:
foreach(ISWiProductConfig cfg in prj.ISWiProductConfigs)
{
foreach (ISWiRelease rls in cfg.ISWiReleases) //InvalidCastException, message: Unable to cast COM object of type 'System.__ComObject' to interface type 'ISWiAuto14.ISWiRelease'. This operation failed because the QueryInterface call on the COM component for the interface with IID
{
...
}
}
or
foreach(ISWiProductConfig cfg in prj.ISWiProductConfigs)
{
foreach (System.Object rls in cfg.ISWiReleases)
{
string typeName = rls.GetType().Name; // typeName == "__ComObject"
ISWiRelease rls2 = rls as ISWiRelease; // rls2 == null
}
Maybe it's Macrovisions error.:(
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 21, 2008
05:45 PM
It looks like you were completely right about the 1-based indexing, but I cannot reproduce the problems you report with the foreach. Can you use the release name instead? If not, I'd suggest either trying to regenerate the COM interop that's been generated, or worst case move to another automation implementation or machine.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 25, 2008
03:39 AM
Error isn't reproduce after reinstall IS2008 and uninstall IS12.
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)