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

  • Home
  • SEARCH
  • 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 6040223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:28:58+00:00 2026-05-23T06:28:58+00:00

I want to reuse some code logic from a self-hosted web application in my

  • 0

I want to reuse some code logic from a self-hosted web application in my Windows Azure web application. Currently I have code like this:

void myFunction( params )
{
   //environment-neutral code
}

I need to rewrite that code to make the program act differently depending on whether is is on Azure:

void myFunctionModified( params )
{
    if( onAzure() ) {
       //run Azure-specific code
    } else {
       //run non-Azure code
    }
}

yes, I know about virtual functions, but I’ll need such code for at least instantiating the right object before I can call those virtual functions.

The problem is to implement onAzure() I need to use stuff from an assembly that is only present on Windows Azure (like RoleEnvironment for example). So I don’t see how I can implement onAzure() so that it doesn’t crash when run outside Windows Azure environment.

How do I make my application act differently depending on what assemblies are present on the system?

  • 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-23T06:28:59+00:00Added an answer on May 23, 2026 at 6:28 am

    If you can’t use conditional compilation symbols as other answers have suggested then…

    Could you try and get a type using reflection that only exists on Azure?
    If it can’t find the type then you’re not on Azure.

    Or, if you want to go down the assemblies route, then you could check AppDomain.CurrentDomain.GetAssemblies() for your Azure assembly.

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

Sidebar

Related Questions

I want to reuse some code like the following: instance ToJavascript j => YesodTemplate
Currently I have some code to replace strings in a file that looks like
I want to reuse some code licensed under a BSD license but I don't
I am planning a Web Application and I am currently evaluating Frameworks. I have
In my project, I want to reuse some code for multiple binaries (.exe). So,
I'm currently developing a couple of modules to reuse code from my controllers on
For my next application i want to use themes to have some eyecandy to
I'm building an ActionFilter to reuse some code for a simple spam block -
I want to reuse some Cucumber steps but can't seem to find the right
I have a web-app-database 3 tier server setup. Web requests data from app, and

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.