469,904 Members | 2,518 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

.NET refuses to update due to dual directories?

Why whenever I create a project in c#, when I compile it, it has got the
resulting executable TWICE in TWO different directories - obj\debug and
bin\debug. WHY?
Sometimes when I'm trying to debug it, when I press F5 the one that's
running is obviously not the same one to the one that i've just made changes
to, as it doesn't seem to update my changes. Why does it do this stupid
behaviour?
Nov 16 '05 #1
2 1119
yes, there are two different directories.

When you are running an EXE, it runs from the bin directory. If you want to
make a reference to an assembly (DLL) from another application, you should
reference the copy in the obj directory.

This is because the bin directory contains the EXE and a copy of every dll
you referenced. If you are making a DLL, then copies of the referenced DLLs
are copied in there as well. If you reference a dll from a bin directory,
and other dlls that you reference are also in that bin directory, your app
will use them instead of picking them up from their own directory. As these
are copies of the dlls, you could end up getting the wrong one.

This means you could make a change to a DLL, recompile just the dll you
changed, then switch over to the EXE to debug your change, and you EXE won't
pick up the change, because you referenced another object in the BIN
directory, and it had made a copy of the old dll, and that's what your app
is referencing.

These directories are on purpose. They are important. Don't confuse them.

On the other hand, if you are making a stand-alone exe, with no assemblies
that you wrote, and you are debugging it, I do not believe that it is
possible for the debugger to be placing a breakpoint in the wrong one...
which is how I interpret your complaint.

Not sure what you mean by referring to VS as "stupid."

I hope this helps,
--- Nick

"Beeeeeves" <beeeeeeeeev@ves> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Why whenever I create a project in c#, when I compile it, it has got the
resulting executable TWICE in TWO different directories - obj\debug and
bin\debug. WHY?
Sometimes when I'm trying to debug it, when I press F5 the one that's
running is obviously not the same one to the one that i've just made changes to, as it doesn't seem to update my changes. Why does it do this stupid
behaviour?

Nov 16 '05 #2
> When you are running an EXE, it runs from the bin directory. If you want
to
make a reference to an assembly (DLL) from another application, you should
reference the copy in the obj directory.
OK, thanks - I didn't know this rule!

This is because the bin directory contains the EXE and a copy of every dll
you referenced. If you are making a DLL, then copies of the referenced DLLs are copied in there as well. If you reference a dll from a bin directory,
and other dlls that you reference are also in that bin directory, your app
will use them instead of picking them up from their own directory. As these are copies of the dlls, you could end up getting the wrong one.
So, presumably if you have a DLL project and a main EXE project, then the
DLL project should have its output location set to the 'obj' directory of
the main exe?

This means you could make a change to a DLL, recompile just the dll you
changed, then switch over to the EXE to debug your change, and you EXE won't pick up the change, because you referenced another object in the BIN
directory, and it had made a copy of the old dll, and that's what your app
is referencing.

These directories are on purpose. They are important. Don't confuse them.
On the other hand, if you are making a stand-alone exe, with no assemblies
that you wrote, and you are debugging it, I do not believe that it is
possible for the debugger to be placing a breakpoint in the wrong one...
which is how I interpret your complaint.
I'm pretty sure it is still doing this... I have now got no DLLs and one
main EXE.


Not sure what you mean by referring to VS as "stupid."
I'll do it to those rules and see if it helps. Thanks


I hope this helps,
--- Nick

"Beeeeeves" <beeeeeeeeev@ves> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Why whenever I create a project in c#, when I compile it, it has got the
resulting executable TWICE in TWO different directories - obj\debug and
bin\debug. WHY?
Sometimes when I'm trying to debug it, when I press F5 the one that's
running is obviously not the same one to the one that i've just made

changes
to, as it doesn't seem to update my changes. Why does it do this stupid
behaviour?


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tomer Ben-David | last post: by
3 posts views Thread by Arthur | last post: by
3 posts views Thread by Mark A Framness | last post: by
5 posts views Thread by John Dalberg | last post: by
1 post views Thread by Riley DeWiley | last post: by
3 posts views Thread by sam | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.