Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem to start a Process
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Infralution Support Forum Index -> .NET Encryptor Support
View previous topic :: View next topic  
Author Message
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Sat Jun 15, 2013 7:30 pm    Post subject: Problem to start a Process Reply with quote

My application has a Check for Updates menu item, whose code looks as follows:

Code:

private static string appPath = Path.GetDirectoryName(Application.ExecutablePath);
private string fileTwuX = appPath + @"\twuxW.exe";
private void checkForUpdates_Click(object sender, EventArgs e)
        {
            IntPtr handle = this.Handle;
            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
            myProcess.StartInfo.FileName = fileTwuX;
            myProcess.StartInfo.Arguments = "/w:" + handle + " http://www.asdipsoft.com/Download/ASDIP%20Concrete-Setup.txt";
            myProcess.Start();
        }

If the application is protected with .NET Encryptor then this code fails because the specified file is not found. I think that this has to do with Application.ExecutablePath, but I'm not sure how to solve the issue. In the unprotected version it works perfectly. Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jun 17, 2013 12:07 am    Post subject: Reply with quote

Code that depends on the disk location of the application assembly can cause issues - however I tried calling Application.ExecutablePath from within the sample application code and it returned the path of the bootstrap executable correctly. Note that it will return the path of the Bootstrap assembly not the original path of the application (which is now loaded from the bootstrap resources). So you would need to have your twuxW.exe file in the same directory as the bootstrap executable.

An alternative to calling Path.GetDirectoryName(Application.ExecutablePath) is to call AppDomain.CurrentDomain.BaseDirectory.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Mon Jun 17, 2013 1:06 am    Post subject: Reply with quote

If I copy the twuxW.exe file to the bootstrap folder, will it be included automatically as part of the bootstrap assembly? I currently include this file separately as part of the installer setup.exe, and the file is located in the root directory. Isn't this the same?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jun 17, 2013 1:37 am    Post subject: Reply with quote

Quote:
If I copy the twuxW.exe file to the bootstrap folder, will it be included automatically as part of the bootstrap assembly?


No - you would need to ensure that your setup/installer deploys the twuxW.exe file to the same directory as the bootstrap executable. I don't know whether you are currently doing this or whether when you were testing and got the error the twuxW.exe was in the same directory as the bootstrap executable. I just suggested that this could explain an error if it wasn't the case.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Mon Jun 17, 2013 2:07 am    Post subject: Reply with quote

This is a dumb question. I just purchased a license of .NET Encryptor. I received the email with the license key, but I don't know how to authenticate my license and the email doesn't have any instructions. Could you please help? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jun 17, 2013 4:11 am    Post subject: Reply with quote

From the Windows start menu use the Start > All Programs > Infralution > .NET Encryptor > Install License menu and then enter your license key.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Tue Jun 18, 2013 12:11 am    Post subject: Reply with quote

I have the same code shown above in two places: one is the Check for Updates menu item. The other one is at the Load event of my application, so that the updates are checked automatically at startup. The menu item is working fine, but for some reason this code doesn't do anything at startup (no error either). Needless to say that it worked fine before the .NET Encryptor was implemented. Can you see what the problem could be? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 18, 2013 7:53 am    Post subject: Reply with quote

No - I can't see anything obvious that would cause that. Have you tried to debug it (as suggested earlier). Alternatively you could add some message boxes to display the path values the code is using.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Tue Jun 18, 2013 11:55 am    Post subject: Reply with quote

Yes, I put a try/catch block. The catch block is never invoked, so the code is being read. Is it possible to force this piece of code to be executed before the protected application is loaded, for example in the bootstrap assembly? That way the issue would be solved. Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 18, 2013 11:31 pm    Post subject: Reply with quote

Yes you can put whatever code you want in the bootstrap project. Of course this code is not encrypted - however in this case there is probably nothing particularly sensitive about the code that requires protections.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Tue Jun 18, 2013 11:43 pm    Post subject: Reply with quote

Where in the bootstrap project? As part of the Main method? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 18, 2013 11:49 pm    Post subject: Reply with quote

I would probably put the code in a separate function and call it from the main method
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Wed Jun 19, 2013 12:54 am    Post subject: Reply with quote

Since the bootstrap Program class is static, the new function has to be static as well, and the keyword "this" is not valid in static methods. Any idea to go around this and make it work in the bootstrap project? Thank you.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jun 19, 2013 1:00 am    Post subject: Reply with quote

Sorry I missed that you are passing a window handle to the external application. Why do you need to do that? This may not be possible to do from the bootstrap, because at this stage you haven't created a window.

I would leaving it in your application and running the debugger and debugging into the code when it executes - you can just open the file and put a breakpoint in it. Then you should be able to see exactly why it is not executing. Alternatively put a message box just before you call Process.Start showing what the fileTwuX path is and what arguments you are passing.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Javier



Joined: 09 Oct 2009
Posts: 215

PostPosted: Wed Jun 19, 2013 1:32 am    Post subject: Reply with quote

The external application closes and restarts automatically the parent process after the updates are installed.

I put a breakpoint before the Process.Start and the path of the file and the arguments are ok. It simply ignores the command, meaning that it cannot close the application. Obviously it has to do with the fact that now it's wrapped by the bootstrap.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> .NET Encryptor Support All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group