|
The whole idea of the 'Any CPU' setting is that it runs on both x86 (32 bit) and x64 (64 bit). Unless you're running into a specific problem that can be resolved by selecting x86 or x64, you should probably leave that setting on Any CPU.
Now to answer your actual question:
If you build x86, you will then IntPtr.Size will be 4. If you build x64 IntPtr.Size will be 8. If you build Any CPU, IntPtr.Size will be 4 on 32 bit windows and 8 on 64 bit windows. So that won't help identify the Any CPU compiler setting.
So, you would need to create 3 project files (2 copies of the original), then add a Conditional Compilation Symbol in each of the project files. Then set the Label's text based on those symbols.
string platformTarget = "unknown";
#if x86
platformTarget = "x86";
#elif x64
platformTarget = "x64";
#elif AnyCPU
platformTarget = "AnyCPU";
#endif
lblPlatformTarget = platformTarget;
You can do something similar with comparing Framework 2 and 4. The upgrade from 2 to 4 should be completely painless.
|
|
|
|
|
any cpu:32 bit machine
x86: 32bit or 64 bit machine
x64: 64 bit machine
|
|
|
|
|
don't think so.
|
|
|
|
|
x86 could run in x64 platform and x32 platform. I used.
|
|
|
|
|
any cpu: 32 bit machine code runs in 64-bit mode on Win64, in 32-bit mode otherwise (i.e. Windows decides based on Win itself and CPU)
x86: 32bit or 64 bit machine code runs in 32-bit mode (or not at all when future x64 CPUs no longer support x86)
x64: code runs in 64-bit mode on x64 CPUs and Win64, or not at all.
For all of them, the process needs to be homogeneous; if parts (referenced DLLs) contain native code of the other persuasion, the app won't load.
|
|
|
|
|
I see.
Thank you very much.

|
|
|
|
|
Apart from the application, you should also test your development environment: developing 32bit applications with VisualStudio 2010 on a Windows 7 (64bit) computer may require some strange settings - it was hard to get it working correctly in our case. Therefore, test also that point.
|
|
|
|
|
Hello,
What is good practice to load an object from a data source?
1 - Static method that returns the object.
2 - Constructor with parameter.
Thank you.
|
|
|
|
|
Use a DataReader .
Yes, if it's merely filling an ActiveRecord-object, then I'd expect initialization using a constructor. No, if it's merely a query that returns a value or a reader, then I'd expect a static method that returns that.
Bastard Programmer from Hell
|
|
|
|
|
The problem with best practices is they are different for different projects and usages. It's your job to understand what the practice is, how it should be used and whether it fits for the goals in your particular usage.
Failure is not an option; it's the default selection.
|
|
|
|
|
|
You know that's not an answer right? Yes, it's our jobs know and understand best practices, but before you can do that you need to learn them. One way to learn is to ask.
|
|
|
|
|
You know that's not a question right?
Failure is not an option; it's the default selection.
|
|
|
|
|
I agree with Eddy (and Mark). I generally use a constructor to do that. But first you need to be really sure that you need an object; I very rarely use custom objects, the existing DataTables and DataRows usually suffice for my needs.
|
|
|
|
|
I tend towards the static method mostly for consistency sake. If I need to return a list of those objects, which I often do, then I want a static method that queries the datasource once and returns a list of the objects.
I don't want that list retrieval method to make a bunch of calls to the objects constructor only to have the object query the datasource.
And of course I want to be able to get a single object in a similar manner as I get my list, thus static methods all the way.
I'm sure an argument can be made for the 'constructor with parameter' way as well. These things are almost never black and white.
|
|
|
|
|
I prefer not to have the object class query the datasource -- I think that couples the class too tightly to the datasource. By using constructors I can instantiate the class from different sources (IDataRecord, XML, etc.) as the situation requires.
In my opinion the class shouldn't know how, where, or whether the data is persisted. I realize that this may be an unpopular point of view. 
|
|
|
|
|
That makes a lot more sense than have a constructor querying the database.
I've never worked with a code base that did it that way, but I'm going to keep that method in mind for the next greenfield project I work on.
|
|
|
|
|
PIEBALDconsult wrote: I realize that this may be an unpopular point of view.
Unpopular with whom? IMO this is the correct way also.
Failure is not an option; it's the default selection.
|
|
|
|
|
Thank you for your response
|
|
|
|
|
Unfortunately the simplest answer to this is 'it depends'. Both approaches can be correct, depending on how complex the object is and what the data source is (i.e. does constructing the object require a database hit?).
I would typically have a layer of model objects which map directly to database rows, and my data access layer would create those from a pseudo-factory (actually, last time I did this, the data access layer instantiated and populated those objects by reflection, and EF does something similar for you). That means that you can do a single query, pull the query results into memory and create a list of data objects without repeatedly accessing the data source.
Then, if those data objects weren't sufficient for what I actually wanted in my application object model, I'd have the application objects take the relevant data objects as constructor parameters.
In the past, though, I have had application objects directly take the data source (a byte array) as a constructor parameter, because in that case the data source was zero cost so the extra indirection wasn't worth it.
|
|
|
|
|
i have an object
Dictionary<int, String[]> temp = new Dictionary<int, String[]>();
The values in temp are:
1 s1
s2
s3
2 s1
s2
I want to transform it into object
Dictionary<String,int[]> temp1 = new Dictionary< String,int[]>();
So i need some kind of grouping
So i want final o/p as
s1 1
2
s2 1
2
s3 1
Please techies reply... thanks in advance
|
|
|
|
|
Does it have to be fast or just correct?
|
|
|
|
|
|
Repost!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
modified 7-May-12 8:43am.
|
|
|
|
|
Hi All,
I have the following problem:
I'm creating a windows application what read map data and draw the map from these information.
The problem is the following:
When I read the shape file I get about 5000 shapes what contain the points what I have to use for drawing. I read these shapes in a foreach loop. I get X, Y coordinates from part of the shape, create vertexes from these coordinates and use these vertexes to draw roads.
I use for this draw function in a class but it seems I get OutOfMemory exception. I have found that I should use one vertebuffer and send this to the drawing function. But I do not have idea how could I insert collections to the vertexbuffer and to the indexbuffer and read the data back when I want to draw the lines.
Does anyone have idea how should I solve this problem? Did anyone meet a problem like this?
Thanks for your help!
Regards,
Norbi
|
|
|
|