|
Hello,
I often wonder what is the difference between build and rebuild. When I am developing a project I sometimes use build and sometimes use rebuild. I seem to get the same results.
What is the purpose of having both when they do the same job?
If there is a difference between the 2, which one should I use and when?
Thanks in advance,
Steve
|
|
|
|
|
And you should get the same results; but, if you read the Visual Studio .NET Product Documentation[^] - specifically about Building, Debugging, and Testing[^] - you would see that a build performs an incrementable build in a debug build, which only compiles source files that haven't changed into the assembly. In release mode, the build option - like the rebuild option in both configurations - cleans out the intermediate and object files (like the assemblies, which is a target output file) and builds all the sources since their object libraries don't exist.
This is true of just about every build system - including make and nmake - I've ever used or have read about. This allows you to compile your changes more quickly in order to get debugging and spending less time waiting for larger projects to recompile.
The result is the same, more or less. Intermediate linking doesn't produce as efficient libraries as rebuilding, which is why the default configuration for release builds has incremental linking turned off. For C# projects, this is reflected by the "Incremental Build" project under the "Advanced" section of the project options dialog.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Are multimple threads allowed to access simultaneously the same method of an instance object?
What happend then? they both run a different 'instance' of the method?
|
|
|
|
|
sb777 wrote:
Are multimple threads allowed to access simultaneously the same method of an instance object?
Yes
sb777 wrote:
What happend then? they both run a different 'instance' of the method?
No, method variables lives on the stack, and each thread maintains its own stack. Example:
public class TestClass
{
public static int Test(int i)
{
int retval = i;
return retval;
}
}
Let's assume that two different threads, tA and tB, invokes TestClass.Test:
tA pushes the 'i' integer argument on its stack, let's say the value is 42, and then it invokes
TestClass.Test.
tB pushes the 'i' integer argument on its stack, let's say the value is 9, and then it invokes TestClass.Test.
In both cases TestClass.Test makes room for the variable retval by pushing an integer to the stack of the current thread. It then sets the value of that integer to the value of i. And the value of i is found on the stack of the current thread. When you write 'return retval' you actually tells the compiler to push retval on the stack of the current thread.
So, in the example above, nothing can go wrong in a multithreaded environment. Things are getting ugly if the example looks like this though:
public class TestClass
{
private static int j;
public int J
{
get:
{
return j;
}
set:
{
j = value;
}
}
public static int Test(int i)
{
int retval = i;
return retval + j;
}
}
Things are looking good right untill retval is added to j . The problem is that j lives on the heap, so both threads will access the same reference to j . This is where you, the programmer, needs to actually think (ugh!). At some point in you code, you must find the sequence of code that isn't threadsafe, and then you must wrap it in a lock block like this:
lock(aReferenceToAnObjectSharedByBothThreads)
{
TestClass.J = x;
int y = TestClass.Test(x + 1);
}
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
First, Thanks for your answer.
Now, why did you use static method for your example? Is the same story true for instance methods?
|
|
|
|
|
You're welcome.
I used static, so I could skip the instantiation part of the code. Instance methods and instance member variables behaves just the same.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
As I understand, there is no need to lock read-only (per method or general) members.
Am I right?
|
|
|
|
|
You're right. the readonly variables has to be initialized in the constructor, and no threads can change them. Problems in multithreaded environments starts, when a thread assumes something about a variable, that can be changed in between line x and line y by another thread.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi all,
Can any body help me on this ?
C# code hangs while opening word in web application. It hangs the moment it encounters the line "Documents.open" it hangs.........
Please help.
Also can anyone please give me email address of Gold. Member No. 118271 i.e. display name UB ?
Thanks in advance
Nitu
|
|
|
|
|
NituP wrote:
C# code hangs while opening word in web application. It hangs the moment it encounters the line "Documents.open" it hangs.........
And not suprisingly. Word - whether visible or not - is a Windows application that depends upon window handles which wouldn't exist for a web application since there is no window manager. There's also many other factors that exist that determine why Word would not start. If the Word.Application object is not accessible by the account under which ASP.NET is running (the local ASPNET user account, by default) or if multiple users are making requests at a time without impersonation. Word was not designed for this purpose. It is recommended that you instead use the System.Xml classes to create or modify a Word 2003 XML[^] file. There's also several articles about this here on Code Project as well, like MS Word 2003 XML Output - ASP.NET[^].
There's many reasons why Word will fail when running within the context of a web server, but without more details it's impossible to know exactly why. It can be made to work with limited support, but it will ultimately tie up your thread pool to handle multiple user requests. You really need to read and understand about COM threading models to understand why, which is beyond the scope of this forum. You can start by reading Understanding and Using COM Threading Models[^] in the MSDN Library, however.
NituP wrote:
Also can anyone please give me email address of Gold. Member No. 118271 i.e. display name UB ?
Email addresses - unless the user specifies them in their signature or description - are not published. Go to the user's profile page[^], click "Messages", and find a message they posted. Then click the "Email" link as opposed to the "Reply" link for that topic. They are emailed directly, regardless of whether or not they unchecked the option to be notified of new replies to the message you selected.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I have an mdi parent that when there is a resizable child in it (that is maximised) - if I try to open up another window(while the other child is still there) that has a fixed single border - the fixed single border form shows up maximised.
Any ideas/solutions to get around this ??
Thanks.
|
|
|
|
|
Hello!
I´m new to C# and wondering if there is a possibility to make something like Javaspaces with C#.
My goal is to write a server that has a huge load of Tasks to complete.
The server capsulate a class with some things, eg. calculations to do and put it in a "space". A client grabs this class from the space, computes it and sends back the result to the server and so on.
I hope you get what i am talking about
stumpi
ps sry for bad english
|
|
|
|
|
Sure it's possible. Practically anything is possible in the world of application design and development. How you would implement such a feature is a different matter.
While there is no particular technology already developed for you in the .NET Framework base class library (BCL), there are many classes that can help you design such an infrastructure. Since you're new to .NET development, you should start by reading Programming with the .NET Framework[^], as well as browse the table of contents for the Class Library[^] reference to see what kind of classes are available.
To find existing implementations - if any implementations for .NET exist currently - you'll need to search the web.
What your describing is simply (i.e., not simple to implement) a distributed system and are used in many applications using many different programming languages. SETI@Home[^] is one of the more famous distributed systems in public domain that is used to help search for extraterestrial life by providing large chunks of radio data to PCs to be processed and sent back the server.
If you look, I'm sure you can find many documents covering distributed systems - even for .NET. This would be a great use of .NET Remoting[^] using a two-way communications channel like the TcpChannel . This would not work so well for XML Web Services of .NET Remoting using a one-way channel like the HttpChannel , because the web (HTTP) by nature is a simple client request/server response mechanism. The servers cannot communicate with the clients unless the client establishes a connectoin with the server to request or post data.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi. I am a new member of Code Project. I have some basic beginner questions, and wonder if this is the place to ask them. I'll ask one, and if there is a better area for beginner questions, please let me know. My current question involves the key word static. Could someone please give me an explanation of it's function? I am reading a Microsoft book on C#, and I am having trouble understanding what static is all about. I looked but do not find a FAQ on this site which answers such questions. Thanks, Steve
|
|
|
|
|
|
The static modifier, keeps the method,property, or field "static in memory". That means it persists and you don't need to instantiate it. You use them all the time when programming in .NET... one very good example is when you use any of the public members of Console such as Write() or Read().
The wole point behind a static keyword is to allow use of the so&so method/field without creating a new instance... How else would you be able to run any of the programs you write? Look at the general structure of a Main method.
[STAThread]
public static void Main(string[] args)
{
Application.Run(new Form1());
}
you can run Main at anytime, and you create a new instance of the Form1 and then the program runs. Also, Application.Run() happens to be a static method as well
Got a coding problem? Hand it to the CodeDevil!
|
|
|
|
|
hi everyone,
I've written a small application for my company and now would like it to integrate with VS.NET 2003. In the integration part, what I specifically want is to have a menu item placed in the context menu of solution explorer such that whenever the user right clicks on any .cs or .vb file, "Open with myApp" comes as a menu item in the context menu.
Can anyone guide me with this? How should I go about doing this? I have seen many applications doing the same, that means this is possible. Some code snippet will be highly appreciated.
thanks in advance...
Cheers !! and have a Funky day !!
|
|
|
|
|
While this won't solve your immediate problem, it's important to understand the design-time features of the .NET Framework. Read Enhancing Design-Time Support[^] in the .NET Framework SDK for more details. Much of what you see in VS.NET when designing with forms and controls is actually provided by classes in the BCL.
For integration like you want, see the Visual Studio Extensibility Center[^]. Also see the Automation and Extensibility Reference[^] in MSDN Librayr, which documents the DTE (Design-Time Environment) object model and gives C# and VB.NET (as well as C++, of course) examples. Whatever you read for VB (as in VB6), the same is pretty much true since the EnvDTE assembly is an interop assembly created from the typelib that automation clients like VB6 use to automate and object library.
Specifically, you'll want to take a look at the VSProjectItem Object[^].
If you look in VS.NET's New Project dialog, you'll also see a couple of extensibility projects that serve as a good start. There may even be a few articles here on Code Project is you search for them.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Can anyone give me independent advice on c# code generators for database tier. I know there are many products out there but its hard to distinguish between them.
I have had a brief look at llblgen Pro, RapTier, CodeSmith, TierDevelopment, IronSpeed.
There are some freeware solutions on "SourceForge.Net" but they seem very limiting.
Thanks in advance
|
|
|
|
|
I've used CodeSmith and MyGeneration.Net, and found both to be very capable. I'm thinking the next thing I will try is NHibernate (an O/R Mapper), which does away with the need for a specific data layer.
There is a long list on http://codegeneration.net/.
my blog
|
|
|
|
|
Thanks Steven for the recommendations, I also wasn’t aware of NHibernate, I will have a look at it. Cheers, Jared
|
|
|
|
|
Is is possible through, and I assume this would be using Platform Invoke, to create a hwnd without creating a Windows.Forms.Form?
Would i have to register a class and create a windows without showing it through windows api or is there some way just to obtain or register a unique hwnd without making a window.
Thank you very much!
|
|
|
|
|
To get an HWND (an IntPtr in .NET) for an existing Window, P/Invoke FindWindow[^].
If you want to create a Window without instantiation a Form *, you can P/Invoke CreateWindow or, preferably, the CreateWindowEx[^] API, which you can read about in the MSDN Library[^].
* Keep in mind that any control or form you create is a window. Each is tied to an HWND (via the Control.Handle property that every control - including the Form class - inherits), just like with native code. Even Java AWT and Swing classes are ultimately tied to an HWND , though through the JVM.
Also, just instantiating a Control derivative doesn't create the window. The control must be set to visible so that the window is actually created and the Control class derivative is tied to the new HWND . This is reflected by the OnHandleCreated event handler and the HandleCreated event.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thats what I though. I just didn't want to use any existing hwnds as i am writing a notify icon tray things and i dont want to tie it in with windows, so that it could be created in a console program for exaple (for whatever reason you would want to do that in the first place really beats me though).
|
|
|
|
|
That's where the NativeWindow class comes in handy, which you can attach to an existing window (including those windows in managed coding using their Control.Handle property).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|