what .net version VS2005 use for C# project

Someone asked on Stack Overflow:

I am porting a project built on VS2008 to VS2005 since the minor .NET version for us have to 2.0 instead of 3.5 and rest of our code is building on VS2005. So I modified the visual studio version from 2008 to 2005 at the .sln file

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005

So I am able to load the .sln into the VS2005. I have some building problem, mainly the “var” and after I modified those lines with real data type, the code compiles and runs.

However at the project assembly reference. I found out that my code is still reference Linq which is from .NET 3.5:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll

When I open up the dialog to add new reference, I could see that the .NET version 2.0, 3.5 and even 4.0 (although the CLR runtime version is 2.0.50727 in most of cases. sometimes 1.x and sometimes 4.0, Linq’s runtime version is 2.0.50727).

I thought that VS2005 only supports .NET 2.0 which seems not that case here. So I guess how can I make sure that my application would only require .NET 2.0 framework. Is it enough to make sure that I only reference .NET 2.0 and below reference?

I posted the following answer, which was chosen as the accepted answer and received 5 upvotes:

As long as the target framework is .NET 2.0 and you don’t reference any libraries that do target higher .NET framework versions, your app should run just fine on .NET 2.0.

That said, I believe Visual Studio 2008 supports multi-targeting, so you should be able to use VS2008 but still target .NET 2.0 as your output type. Additionally, VS2010 and VS2012RC also support .NET 2.0 only projects.

To answer the exact question in the title (for the benifit of those who find this page by its title) the .NET version used by default in Visual Studio 2005 is .NET v2.0.

Notable comments

Nate (0 upvotes): As far as I know, there is no reason a .NET 2 app couldn’t (or shouldn’t) reference a .NET 3.5 or 4.0 class library. Doing so ovsiously changes your deployment requirements, but it will save you from converting your project from .NET 2 to .NET 3.5 just to make a reference. It just so happens that you already converted your project.


Originally posted on Stack Overflow — 5 upvotes (accepted answer). Licensed under CC BY-SA.

Applicability of Business Architectures in XNA 4

Someone asked on Game Development:

I’ve done a lot of C# programming and the architecture we use of late is a MVC => PresentationService => Domain Service And/OR DataService => Repository with a UnitOfWork and a messaging bus. In web applications this gives a pretty clean and flexible design that’s extensible but is also stateless.

I’ve been working on a 2D starter project in XNA and I find these layers are still useful until I get to the interface and start trying to deal with knowing the states of everything, keeping the sprites and bounding rectangles and detecting clicks and drags.

What patterns should I be looking at that maybe I just wasn’t exposed to doing enterprise architecture but are clearly needed in a game.

Which concepts might I need to let go of when doing a game because they are not applicable.

I posted the following answer, which was chosen as the accepted answer and received 7 upvotes:

I’m not a big fan of these on-site link posting answers, but in this case I feel there are several questions that address this.

You may also want to browse some other questions in the design-patterns tag on this site.

With respect to porting skills and patterns learned while developing business apps on the Microsoft Stack to game development, I think you’re in a big boat with a lot of other developers. My guess is that you are very new to game development, so my advise would be to skip any and all patterns and best practices to get your first game working.

Some additional thoughts

  1. Keep the scope of your first game small
  2. Get something on the screen as fast as possible
  3. Make that thing on the screen react to user input
  4. Start implementing the rules of your game
  5. Finish testing, and ship your game
  6. Refactor the best bits of code into a common library
    1. Implement patterns you think fit, based on your experience with shipping your first game
  7. Start your next game and continue working on your library
Notable comments

Nate (0 upvotes): @HonorableChow I understand where you are coming from; but I’ve read about too many games that were never finished due to getting bogged down in design and re-engineering. I have a few in that category myself.


Originally posted on Game Development — 7 upvotes (accepted answer). Licensed under CC BY-SA.

Large MVC controller for a web-based "Wizard" - what are some ways I could reduce size and redundancy?

Someone asked on Stack Overflow:

I have a very large (77 actions) controller that I am using to make a site with wizard-like functionality. The site is like a “job application manager” with multiple components such as an admin component and an end-user component. The component I’m working with is the part where the user would actually fill out a job application. The way things are structured with the other components, it makes the most sense to put all of the job application stuff in the same controller. All of these actions perform similar things but on different models, like so:

public class ExampleController : Controller
{
    public ActionResult Action1() 
    {
        Guid appId = new Guid(Session["AppId"].ToString());
        ... // logic to pull up correct model
        return View(model)
    }

    [HttpPost]
    public ActionResult Action1(FormCollection formValues)
    {
        Guid appId = new Guid(Session["AppId"].ToString());
        ... // logic to update the model
        return RedirectToAction("Action2");
    }

    public ActionResult Action2()
    {
        Guid appId = new Guid(Session["AppId"].ToString());
        ... // logic to pull up the correct model
        return View(model)
    }

    ... // on and on and on for 74 more actions
}

Is there any way to reduce some of the constant redundancy that’s in every one of the actions? Here is what I am thinking:

  • Creating a member variable Guid to store the appId and then overriding OnActionExecuting to populate this variable. Is this a good idea?
  • Implementing some kind of paging to cut down on the number of actions. Any suggestions on how to do that?

I posted the following answer, which was chosen as the accepted answer and received 2 upvotes:

I would say yes to your first point and “it depends” to your second. Don’t change your design just because you have a lot of methods, if all 77 ActionResult methods make sense to have, then keep them around.

Using a member variable and overriding OnActionExecuting seems like a great way to refactor that appID Guid code into a single place, so you can quickly and easily modify it in the future.


Originally posted on Stack Overflow — 2 upvotes (accepted answer). Licensed under CC BY-SA.

How to create biomes

Someone asked on Game Development:

I am creating an 2D XNA Tile Based Platformer. I have a tile engine and a world/terrain generator. However, I am trying to create biomes or areas, For example, Desert in one part of the world, ocean on the ends, City in the middle, forests scattered around etc. I can easily make it generate them, but My problem is defining the actual areas to be generated in.

I posted the following answer, which was chosen as the accepted answer and received 5 upvotes:

Without any specific knowledge of your generation algorithm, I would suggest the following.

Assuming that your world is defined in a multi-dimensional array Tile[999,99]

  1. Decide how many “biomes” you want and of what type
  2. Define the size of each biome
  3. Go through your world array, and pick a start point for each biome
  4. Update the world array with each biome’s tile data

For example:

Tile[,] World = new Tile[999,99];
Tile[,] Ocean = new Tile[50,10];
// assume we want the ocean to be top left of the world, flowing off the edge
for(int i = 0; i < 50; i++)
{
    for(int j = 0; j < 10; j++)
    {
        World[i,j] = Ocean[i,j];
    }
}

You could, as @Nathan suggested, use a distance from water to define which tile-set to use for each area. This could help keep your maps looking fresh and consistent, yet still be generated on-demand.

Notable comments

Nate (0 upvotes): @Cyral Great! Glad it was helpful.

Nate (1 upvotes): A side scroller makes it even more simple, you just have to decide the start x and stop x for each biome.


Originally posted on Game Development — 5 upvotes (accepted answer). Licensed under CC BY-SA.

What is the &quot;pricing standard&quot; on Windows Phone?

Someone asked on Game Development:

On iOS, I find it is more usual to see light versions of a game for free (with ads and less features) and a full version for a cost and all the features.

On Android, I see more games that have both a full version for free and one for a cost. One with ads and the other without.

On WP7, how are games usually priced?

Talking about a rather simple and small game here and I’m trying to figure out how to price it. I’m thinking of going for a 1$ app with full features no ads, but I’m not so sure. Would it be more profitable to put it for free with ads instead? How do other developers usually make that choice?

I posted the following answer, which was chosen as the accepted answer and received 2 upvotes:

If your game has little or no replay value (which is not a bad thing, but it does change the way that I think you should price your wares) then you should charge your fee upfront. Get your money and be done. It will reduce the number downloads of your game gets, but at least you will make some money. Since you anticipate 30-60 minutes of total playtime for your game showing ads wont make you very much money. Ads supported games/apps work best when there is a strong reason to come back and play or use the app again (and thus see more ads).

Based on your comments, question, I think that $.99 is the most you should charge for a game that plays through in 30-60 minutes. Most short games are in that price point. I think that Angry Birds (mentioned in another answer) is the exception likely due to its low/free cost on other platforms. Most Xbox Live games on WP marketplace are in the $2.99 range, but most of these provide at least a few hours of gameplay before being boring, and IMHO many provide tens of hours of play.


Originally posted on Game Development — 2 upvotes (accepted answer). Licensed under CC BY-SA.

WP7 Screen Shot Requirements

Someone asked on Stack Overflow:

Microsoft declined to submit my application because I took a screen shot of the game which included the actual emulator.

Looking at this answer, the person says that I should us the snipping tool when I have made the phone emulator at 100%. And indeed, the snipping tools spits out an image of that screen at exactly 480x800 which is exactly what Microsoft wants. However, whenever I use the snipping tool, there is still the top black border of the WP7 remaining. I’ve looked at a few images on the Marketplace and other applications have it as well…I think. Some don’t. Can anyone advice me on this please? How I can avoid getting penalised…again.

Will this suffice?

enter image description here

I posted the following answer, which was chosen as the accepted answer and received 2 upvotes:

If you update to the Windows Phone 7.1 SDK and Emulator, the new emulator has a built-in screenshot function to take screenshots without these issues.

emulator screenshot taking utility

I have never had my app rejected due to a screenshot taken from the emulator, I can’t say you wont have issues, but assuming everything else in your screenshot checks out; the images from the emulator are the correct size and should be approved.

Notable comments

Shawn Kendrot (3 upvotes): You can collapse the SystemTray for the page by doing: shell:SystemTray.IsVisible=“False” within the markup for the Page

Nate (0 upvotes): The black bar in the image you posted seems to big to be just for that part of the OS; however, I’ve never had any problems submitting screenshots generated form the emulator. That said, it looks like you’ve got an XNA game, maybe you are not setting it to fullscreen, so you get a larger area not used?

Nate (0 upvotes): @subby Does the border show up in the emulator? Does the border show up when you run your app on a real device? Can you upload the file that gets output when you click “save” from the emulator tool?

Nate (0 upvotes): @Subby I’m not sure what black border you’re talking about… Can you upload your screenshot as part of your post so we can take a look and try to diagnose what it is?


Originally posted on Stack Overflow — 2 upvotes (accepted answer). Licensed under CC BY-SA.

What is the correct way to handle long running service operations with WCF hosted in IIS?

I asked this on Stack Overflow:

I am building a WCF service that will expose several operations, it will run in IIS because it needs HTTPS endpoints. Most of the operations will perform within seconds or less; however, one or two of these operations will take between 5-90 minutes.

The primary consumer of this service will be an ASP.NET MVC application; what is the correct way to do handle this?

Should I jackup the timeout and do some ajax calls? Should I add a table to my database, and have the long running operations update this database, and have the web interface poll this table every minute? I’m not sure what (if there is) the generally accepted best practice for this.


Localghost answered (1 upvotes):

I wrote something similar for my senior project, basically a job scheduling framework.

  1. I chose to go down the path of storing the “status” of the “job” in the database.
  2. I wrote a manager windows service that implemented a WCF client (proxy)
  3. I wrote a WCF Service that implemented my “worker host”.

The manager service would read the queue from the database, and hand out work to all of my “worker hosts”. The reason I had windows service perform this task as opposed to just having the UI talk directly to the worker host, was because it gave an extra level of control over the whole process.

I didn’t like the idea of having “the network cable unplugged” from my worker host, and never getting a status update again from this specific job. So, the windows service gives me the ability to constantly monitor the progress of the WCF worker host, and if a connection error ever occurs (or something else unexpected), I can update the status to failed. Thus, no orphaned jobs.

Notable comments

Nate (1 upvotes): @Noah, the long running operations are not returning much data, until they are complete, where they return about a 50kb message.


Originally posted on Stack Overflow — 10 upvotes. Licensed under CC BY-SA.

WPF Search button function

Someone asked on Stack Overflow:

Possible Duplicate:
Windows Phone 7 Search Button

I think that all Windows Phone mobiles have a search button (phisical or not).

Actually, they have three buttons: Back button, Windows Logo button, Search button.

Is possible to modify the function of this button (as Back button). Something like OnSearchKeyPress (as event handler).

Its possible?

I posted the following answer, which was chosen as the accepted answer and received 2 upvotes:

This is not possible, because that could seriously alter the behavior of the phone. There is a search task you can use, for more info, see this MSDN article on it.


Originally posted on Stack Overflow — 2 upvotes (accepted answer). Licensed under CC BY-SA.

how can programs tell if you&#39;ve used them past them demo period?

Someone asked on Stack Overflow:

On certain programs you can run them on a demo period for say ‘ten tasks’ or ‘5 hours’ before you need to decide to purchase them to keep using them, but if you delete and uninstall the program then reinstall it, it knows that its been previously installed and wont let you run the demo again.

How does it do this ? When you download it does it send a identifiing number (ip ?) to the cdn to let it know youve downloaded it before, or when the program itself installed does it check to see traces of previous installation ?

I posted the following answer, which was chosen as the accepted answer and received 1 upvote:

There are many ways this can be implemented.

The easiest way to implement (and also the easiest way to bypass)

  • On first run, create a registry (or text file) entry somewhere
  • Add 1 to the counter every time the task (or the app) is run
  • Do not include this file/registry in the installer app (so it will persist after uninstallation)
  • If at any time the count is too high, notify the user that the trial has expired.

Using image diff tools this method is pretty easy to identify and overcome.

The hardest method to overcome or bypass is to use a server. On the first run, generate a hash code based on the users computer name, drive serial number, etc, and post this to your server. The server then tracks this as a unique installation, and allows the app to run. Each time you run the app, you update the server. This way, the user cannot find the breadcrumbs and delete them, since they are on your server. The down side, is that this method will require an Internet connection.

There are probably much more sophisticated methods to achieve this result, but the above are both implementations I’ve run across.


Originally posted on Stack Overflow — 1 upvotes (accepted answer). Licensed under CC BY-SA.

How can I get the IP address from the user client in C#?

Someone asked on Stack Overflow:

I’m using this code that I found in Get public IP using DynDNS and WebRequest C#

to get the IP address. But I just get the IP Address from the server and what I need is the IP address from the user that is connected to my web application.

String direction = "";
WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
using (WebResponse response = request.GetResponse())
using (StreamReader stream = new StreamReader(response.GetResponseStream()))
{
    direction = stream.ReadToEnd();
}

//Search for the ip in the html
int first = direction.IndexOf("Address: ") + 9;
int last = direction.LastIndexOf("</body>");
direction = direction.Substring(first, last - first);

I posted the following answer, which was chosen as the accepted answer and received 2 upvotes:

If you are running a web app, and you want your “client’s” IP, you need to use the UserHostAddress.

var userAddress = HttpContext.Current.Request.UserHostAddress;

Originally posted on Stack Overflow — 2 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.