Re: detect (and install) office 2003 PIAS - newbie to setup projects
From: Ricardo Drizin (ricardoSPAMyourass_at_linux.ime.usp.br)
Date: 11/10/04
- Next message: Ricardo Drizin: "Re: VSTools Known Microsoft BUG"
- Previous message: Ricardo Drizin: "OOP (and design patterns) in VSTO?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Nov 2004 10:09:36 -0200
Some code/ideas that may be helpful to someone:
1) Detecting Office Interops
public class Class1 //: System.Configuration.Install.Installer
{
[STAThread]
static void Main(string[] args)
{
System.Reflection.Assembly x, y, z;
// these strongnames you can find in file __AssemblyInfo__.ini at
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e
9429c
try
{
x = System.Reflection.Assembly.Load("Microsoft.Office.Interop.Excel,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
y = System.Reflection.Assembly.Load("office, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c");
z = System.Reflection.Assembly.Load("Microsoft.Office.Interop.Access,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429cs");
// etc...
}
catch (Exception)
{
MessageBox.Show("Interops not installed.\n" +
"Read instructions at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrtskInstallingOfficePrimaryInteropAssemblies.asp");
}
}
2) Installing Office Interops. (Not sure if it is the best practice, but..
it works... anyone has comments on this?)
- In the Setup Project, open the "File System" (View - Editor - File
System), Add Special Folder (right-click) "Global Assembly Cache", and add
the needed DLLs to the folder. Since you cannot directly refer to the DLLs
that are in your GAC, you can copy (from DOS PROMPT) from GAC to another
directory.
(ex: COPY
C:\WINDOWS\ASSEMBLY\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e
9429c\Microsoft.Office.Interop.Excel.dll C:\interops\ )
3) Script to register FullTrust on your assembly hash:
' Script for registering FullTrust on assembly dll
' Works even being run from shell (command prompt) as from windows installer
' For Windows Installer you should put this as as a "Custom Action" under
"Commit" folder. Also put "[TARGETDIR]" on "CustomActionData" property, so
the script can find your dll.
'
strPath=""
on error resume next
strPath = Wscript.scriptfullname ' Wscript is only for shell
on error goto 0
if len(strPath)=0 then ' Registering from Windows Installer
strPath = Session.Property("CustomActionData")
else ' Registering from Shell
set fso = CreateObject("Scripting.Filesystemobject")
strPath = fso.GetParentFolderName( strPath ) ' of course you
should put a relative path from this script to the dll
strPath = fso.GetParentFolderName( strPath )
end if
set obj=CreateObject("WScript.Shell")
appname="MyAppName"
dllname = "mydll"
params=" -u -addgroup ""All_Code"" -hash SHA1 -file """ & strPath & "\bin\"
& dllname & ".dll"" FullTrust -name """ & appname & """ -description """ &
appname & """"
' Unregistering previous versions
call obj.Exec("%WINDIR%\Microsoft.NET\Framework\v1.1.4322\caspol.exe -pp
off -u -rg """ & appname & """")
hora = now() + cdate("00:00:05") ' HACK - since Exec calls are async,
wait a few secs so unregistering comes before registering.
while (now()<hora)
wend
' Registering
set caspol =
obj.Exec("%WINDIR%\Microsoft.NET\Framework\v1.1.4322\caspol.exe -pp off" &
params)
b=caspol.stdout.readall
' There's no ExitCode being returned ? same ExitCode on success or failure,
so we'll check for string in output.
Select Case InStr(b,"ERRO") ' works in English (ERROR) or Portuguese (ERRO)
Case 0 'MsgBoX("Successfully registered assembly.")
Case Else MsgBox("Error registering assembly.")
End Select
--------------------------
Maybe that is helpful for setup projects.
Ricardo Drizin
Mondial Informática
"Iouri Simernitski (MS)" <iouris@micro.nospam.soft.com> escreveu na mensagem
news:w1x7D6tsEHA.2092@cpmsftngxa10.phx.gbl...
> Ricardo,
> the only supported way to install PIAs is by using Office setup. You could
> write a custom action for your installer that woud try to load the Word or
> Excel assembly by strong name to check if it is installed, but you cannot
> install it if it is missing.
> If you are using the VS setup and deployment project for installing VSTO,
> it is not supposed to alter the CAS policies. It is up to you to decide
> what policy you want to deploy. By default, in a development invironment,
> the assembly is trusted by URL at project creation time. In general, it is
> wise to use stronger evidence when deploying an assembly in a production
> scenario - publisher, strong name or Authenticode.
>
> iouri
> --------------
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
- Next message: Ricardo Drizin: "Re: VSTools Known Microsoft BUG"
- Previous message: Ricardo Drizin: "OOP (and design patterns) in VSTO?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|