That "could not find part of the path" message is sometimes security
related. So if you're impersonating a limited user you can't update
files in the Program Files folder. 

Phil Wilson 


________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dana
Gutride
Sent: Tuesday, November 14, 2006 9:54 AM
To: wix-devs@lists.sourceforge.net; wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] [WiX-devs] Managed Code Custom Action & Reading
XmlFile


(including wix-users on this thread)

It might be better to place this thread on the wix-users list because it
seems to fall into that category rather than the devs list.  One thing I
should mention is managed code custom actions are definitely not
recommended.  There have been several very detailed sites mentioned on
this list in the past that explain exactly why that is so ( see
http://www.tramontana.co.hu/wix/lesson3.php#3.5)

The path to the file is not different during a deferred action, but you
do not have access to your public properties at this point in the
install.  That means even if you figured out a way to get your C# custom
action to work with a c++ helper dll or some sort of shim, when you
defer the custom action, you wouldn't be able to access the
INSTALLLOCATION property.  To see what I'm saying, you might want to
replace that property with a hard coded value and see if your custom
action still fails. 

Dana



On 11/14/06, carlldev <[EMAIL PROTECTED]> wrote: 


        To be more specific:
        I'm using a managed code custom action (C#).
        
        // this works up to....
                public static int DoMyAction(long handle)
                {
                    // get the msi's handle
                    IntPtr msiHandle = new IntPtr(handle); 
                    try
                    {
                        // get the installationpath
                        string installationPath =
MsiHandler.GetProperty(msiHandle,
        "INSTALLLOCATION") + @"\";
                        installationPath =
installationPath.Replace(@"\\", @"\");
        
                        // get the path to the xml file
                        string filePath = installationPath +
@"myfile.xml";
        
        //... here. It fails here (file not found) 
                        try
                        {
                            // open the xml file and get the root
                            XmlDocument doc = new XmlDocument();
                            resources.Load(filePath);
        
        Are you saying that the path to the file is different during
deferred
        execution to when the file is actually installed?
        
        
        You really shouldn't be able to access any properties you need
in a deferred
        custom action.  I do something similar in our installer, I lay
down a config 
        file, open it up and replace some variables with a custom
action.  I use the
        following immediate custom action to write to the
CustomActionData property,
        then in the deferred custom action, I access that property and
use it to 
        read the file.
        
        <CustomAction Id="SetDeferredProp"
Property="DeferredCustomActionName"
        Value="[FILEDIR]" />
        
        Dana
        
        
        On 11/14/06, carlldev < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
        >
        >
        > Thanks for your quick reply.
        >
        > I tried setting the customaction to deferred but that also
doesn't work. I
        > don't know how to access files through the CustomActionData
property. 
        > I don't have any problems accessing property values either - I
can access
        > the properties I need. I just can't touch any files.
        >
        > Maybe I can try it a different way - by including the xml file
as a binary 
        > inclusion and opening that? Then it is technically not an
installed file.
        > But I can't find a good example of doing that either. Most
examples just
        > execute binary files.
        >
        > Any more ideas? 
        >
        >
        > Dana Gutride wrote:
        > >
        > > Two possible ideas come to mind.  1) Is your custom action
scheduled to
        > > run
        > > as a deferred custom action?   2) Depending on when you are
attempting 
        > to
        > > execute this custom action, you might be having some
difficulty
        > accessing
        > > the msi properties.  Deferred custom actions have access to
only a very
        > > limited number of properties (search for CustomActionData).
The custom 
        > > action you are describing would need to be deferred and use
the
        > > CustomActionData property if it's accessing any installed
files.
        > >
        > > See this section of the tutorial for more info: 
        > > http://www.tramontana.co.hu/wix/lesson3.php#3.6
        > >
        > > Dana
        > >
        > >
        > > On 11/14/06, carlldev < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
        > >>
        > >>
        > >> Hi there,
        > >>
        > >> I have a working Custom Action that reads an installed
XmlFile and
        > >> executes 
        > >> a command line a number of times with parameters extracted
from the
        > >> xmlfile.
        > >>
        > >> The code works fine if I put it after InstallFinalize but
that means if
        > >> the
        > >> command line execution fails there is no way to rollback
the
        > >> installation.
        > >>
        > >> I have added debugging to the code and it reveals this:
        > >> 'Could not find a part of the path 'C:\Program 
        > >> Files\Product\Resources.xml'.'.
        > >>
        > >> But since the code is being executed after InstallFiles the
xmlfile
        > >> should
        > >> be there.
        > >>
        > >> The custom action (in Wix) looks like this:
        > >> <CustomAction Id="DoMyAction" BinaryKey="CustomActions"
        > >> DllEntry="DoMyAction" />
        > >> <Custom Action="DoMyAction" After="InstallFiles">NOT
Installed</Custom> 
        > >>
        > >> Any help would be appreciated.
        > >> Thanks
        
        
        --
        View this message in context:
http://www.nabble.com/Managed-Code-Custom-Action---Reading-Xml-File-tf26
28948.html#a7341265
        Sent from the wix-devs mailing list archive at Nabble.com.
        
        
        
------------------------------------------------------------------------
- 
        SF.net email is sponsored by: A Better Job is Waiting for You -
Find it Now.
        Check out Slashdot's new job board. Browse through tons of
technical jobs
        posted by companies looking to hire people just like you.
        http://jobs.slashdot.org/
        _______________________________________________
        WiX-devs mailing list
        WiX-devs@lists.sourceforge.net 
        https://lists.sourceforge.net/lists/listinfo/wix-devs
        


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to