Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6091407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:19:26+00:00 2026-05-23T12:19:26+00:00

I am trying to create a Worker Role project for Windows Azure that loads

  • 0

I am trying to create a Worker Role project for Windows Azure that loads a custom EXE upon startup. I adapted the code from David Chou’s Jetty server example found here:

http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx

Using Visual Web Developer 2010, I created a new Cloud project for Visual C# and dropped in his Worker Role class code shown here:

namespace WorkerRole1
{
    public class WorkerRole : RoleEntryPoint
    {
        public override void Run()
        {
            string response = "";
            string S = "";

            try
            {
                System.IO.StreamReader sr;
                string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Port.ToString();
                string roleRoot = Environment.GetEnvironmentVariable("RoleRoot");

                S = "roleRoot is: " + roleRoot;
                Trace.TraceInformation(S);

                // string myAzureAppHome = roleRoot + @"\approot\app";
                string myAzureAppHome = System.IO.Path.Combine(roleRoot + @"\", @"approot\");

                S = "myAzureAppHome is: " + myAzureAppHome;
                Trace.TraceInformation(S);


                // string jreHome = roleRoot + @"\approot\app\jre6";
                Process proc = new Process();
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.RedirectStandardOutput = true;
                //proc.StartInfo.FileName = String.Format("\"{0}\\bin\\java.exe\"", jreHome);
                // proc.StartInfo.Arguments = String.Format("-Djetty.port={0} -Djetty.home=\"{1}\" -jar \"{1}\\start.jar\"", port, myAzureAppHome);
                proc.StartInfo.FileName = String.Format("\"{0}\\myAzureAppPRJ.exe\"", myAzureAppHome);

                S = "Attempting to run file: " + proc.StartInfo.FileName;
                Trace.TraceInformation(S);

                proc.EnableRaisingEvents = false;
                proc.Start();
                sr = proc.StandardOutput;
                response = sr.ReadToEnd();
            }
            catch (Exception ex)
            {
                response = ex.Message;
                Trace.TraceError(response);
            } 
        }

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
    }
}

The problem is that the directory I am getting back for the RoleRoot does not match where my “app” support files are showing up when I run the project against the storage emulator. The “app” folder ends up in this directory which I found by searching the WindowsAzureProject2 directory tree:

C:\Users\mycomp\Documents\Visual Studio 2010\Projects\WindowsAzureProject2\WorkerRole1\app

But GetEnvironmentVariable(“RoleRoot”) reports the following as the RoleRoot directory as dumped by my Trace statement:

C:\Users\mycomp\documents\visual studio 2010\Projects\WindowsAzureProject2\WindowsAzureProject2\bin\Debug\WindowsAzureProject2.csx\roles\WorkerRole1

Which of course leads to a file not found Exception when proc.Start() is called because the custom EXE file is in the former directory, and not the latter.

Can anyone tell my why the roleRoot path appears to be botched and what I can do to fix this? Note, I’m aware of the double backslash problem before the EXE in my assignment to proc.StartInfo.FileName (is Visual Web Developer C# different from Visual Studio Pro C#?), but fixing that would not change the path problem I am having since the directory being returned by GetEnvironmentVariable(“RoleRoot”) flat out does not contain my “app” directory.

UPDATE: After doing some more reading it appears to me that what’s really happening is that the “approot” directory is not being created and my “app” folder files are not being copied over either. I still can’t figure out why.

— roschler

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:19:27+00:00Added an answer on May 23, 2026 at 12:19 pm

    Looks like you didn’t add the files in the app directory to the Visual Studio project. Make sure they’re added and have their “Copy to Output Directory” property set to “Copy Always” (or “Copy if Newer”). Then they should end up under %RoleRoot% like you expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What i'm trying to create is a background worker that executes a few processes
I'm trying to create a worker process for Azure and I'd like to test
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying to create a thread class that executes a functor from an adapter.
I am trying to call an executable inside of a worker role I tried
I've got a background worker and I'm trying to get it to create an
I am trying to create an application that uses <authorization> rules to limit the
I'm having problem (basically, I'm confused.) while trying to create a worker thread for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.