Page 1 of 1

Calling a .NET assembly

Posted: Sun Jul 11, 2010 2:01 pm
by yosilevy
Is there a way to call a .NET assembly similar to the Call DLL plugin? (assuming running on Vista/7 on which .NET is surely installed).

Thanks.

Re: Calling a .NET assembly

Posted: Mon Jul 12, 2010 2:17 pm
by mills
Unfortunately, it is not possible to call a .NET assembly at this time like "Call DLL Function", since we can't guarantee the presence of the .NET framework.

The best thing to do at this time would be to build a console application that makes use of the assembly, then run that using "Run Program As".

Re: Calling a .NET assembly

Posted: Tue May 03, 2011 5:08 pm
by pokr2
And what about "Run .NET Installer class"?

Thanks, regards,

Octavio

Re: Calling a .NET assembly

Posted: Tue May 03, 2011 7:23 pm
by giaviv
Octavio,

That's something else - what exactly are you trying to do?

Re: Calling a .NET assembly

Posted: Wed May 04, 2011 3:50 pm
by pokr2
Giaviv,

I was trying to run some code hosted in a managed code DLL at install time. So I found this thread :-)
What I've done:
- Create a DLL Project in Visual Studio, and add an Installer class to it, overriding the Install() method, where you put the code you want to run (there are other entry points: Commit(), Rollback() and Uninstall()).
- Add the resulting DLL to your InstallAware project as a support file.
- Call it from the script at the desired moment using the "Run .NET Installer Class" command. Use the $SUPPORTDIR$ variable to specify the path to the DLL.
- My project installs .NET Framework (if not available already in the host machine) BEFORE calling the DLL, so I can guarantee the necessary runtime support.

Seems to work great!

Regards - Octavio

Re: Calling a .NET assembly

Posted: Wed May 04, 2011 5:33 pm
by giaviv
Yep that would be to solution - thanks for sharing!

Re: Calling a .NET assembly

Posted: Thu May 05, 2011 1:47 am
by bokkie
Octavio,

Thanks for the heads-up on that and it works well. When I tested it, I found the call to the Install(...) method is called twice even though I have only one reference to "Run .NET Installer Class". Did you experience that as well? I have a hunch that the internals of the installer might be doing that but I'm not sure. I'm not sure if I'd need to use it but it's something I'll keep in mind if I have ever the need to do so.

Re: Calling a .NET assembly

Posted: Fri May 06, 2011 7:47 pm
by pokr2
Hi bokkie,

Sorry for the late answer, it's been a tough week...
I haven't observed any duplication of calls, and put some WinForms MessageBoxes in the code for checking. During install, there is a call to Install and a call to Commit (I'm using IA 9 R2).
BTW, you can log all the assembly activity by means of using Context.LogMessage("I'm here!"); in your methods.
The log file is generated in the support directory (which is normally %TEMP%\mia1); you need to grab it before hitting the 'Finish' button of the installer, because the whole folder will be deleted after installation finishes. Surely there's a way to move the log to another place, but haven't had time to investigate :-).

Regards - Octavio

Re: Calling a .NET assembly

Posted: Wed Apr 18, 2012 12:36 am
by pushpankar
hi
i am managed to call a ,net installer class using Run .net installer method of installaware script
in the Install method i need to set the Target dir path (path where product gets installed)

in windows i used to get it through

Me.Context.Parameters.Item("DIR").ToString
how should i get in a installer class using install aware.

Public Overrides Sub Install(ByVal savedState As IDictionary)
MyBase.Install(savedState)
If ProjectOpKey.OpkeyEdition <> OpkeyEditions.Lite Then
Dim LV As New LicenseValidator
LV.DirPath = Me.Context.Parameters.Item("DIR").ToString /////////here i am getting the target dir path.
If LV.ShowDialog = Windows.Forms.DialogResult.OK Then
Else
Throw New InstallException("Rolling Back Installation...")
End If
End If
End Sub

Re: Calling a .NET assembly

Posted: Wed Apr 18, 2012 9:07 am
by FrancescoT
Dear User,

please do not post the same question in different forums. I have already replied to you in Plug In Forum.

so please check:
http://www.installaware.com/forum/viewtopic.php?f=3&p=31021#p31021


Regards