473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

using C# when adding new feature

Hello!

We have MFC application from VC6. Assume we compile the MFC application in
VC8.
Does anything special be done to the MFC application accept remove all the
errors before being able to use .NET
for new feature.

When we want to add new feature to the application using .NET is it then
possible to use C# insted of C++?
I just think that it would be an advantage using C# instead of C++ will
cause less error beacuse it's an easier language. Compare this you create an
application quicker when using Java then C++ beacuse it's an easier language
and the possibility of strange errors in the future is much less with Java.
C# is quite similar to java.

//Tony
Nov 17 '05 #1
3 1285

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:WR*********************@newsc.telia.net...
Hello!

We have MFC application from VC6. Assume we compile the MFC application in
VC8.
Does anything special be done to the MFC application accept remove all the
errors before being able to use .NET
for new feature.

When we want to add new feature to the application using .NET is it then
possible to use C# insted of C++?
I just think that it would be an advantage using C# instead of C++ will
cause less error beacuse it's an easier language. Compare this you create
an application quicker when using Java then C++ beacuse it's an easier
language and the possibility of strange errors in the future is much less
with Java.
C# is quite similar to java.


Yes. If you get your VC6/MFC code to compile on VC8 with /clr (resulting in
a managed app - or at least a partially managed app), then you can implement
new forms in C# and use them in your MFC application.

Whether it's any easier or less error prone is a more controversial
question. I'd argue that the primary reason languages like C# and Java are
easier to program in has more to do with the framework (.NET or Java) than
language syntax.

It's very easy to create WinForms in C++ and you shouldn't have any more
errors in those forms than their equivalents in C#. Given that you already
have a C++ application (and hence, C++ experience), I'd expect you might
even have fewer errors if you stick to C++ for new work regardless of
whether it's managed or native.

-cd
Nov 17 '05 #2
You should know that writting in C# is a much better, less bug prone
exception.

I haven't done real measure but I won't be surprise if the same code in
ManagedC++ is typically 50% bigger (in term of byte size of the source code
files) for writing the same set of functionalities.
That 50% time to write & 50% more opportunity for bugs!

As for pure (unmanaged) C++, some features are simply unavailable or hard to
mimic.

On the other hands in some case using ManagedC++ is a much better solution
than C# if you've got complex interop or lots of function to 'redeclare' in
C#.
Nov 17 '05 #3
"Lloyd Dupont" <ld@NewsAccount.galador.net> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
You should know that writting in C# is a much better, less bug prone
exception.

I haven't done real measure but I won't be surprise if the same code in
ManagedC++ is typically 50% bigger (in term of byte size of the source
code files) for writing the same set of functionalities.
That 50% time to write & 50% more opportunity for bugs!

As for pure (unmanaged) C++, some features are simply unavailable or hard
to mimic.

On the other hands in some case using ManagedC++ is a much better solution
than C# if you've got complex interop or lots of function to 'redeclare'
in C#.


Many of your observations are true for the old C++ Managed Extensions
syntax, but not fo the new C++/CLI syntax.

In some cases, C++/CLI is still more code to write, like in this one:

<code language="C#">
Sting Text {
get() { ... }
set() { ... }
}
</code

<code language="C++/CLI">
property Sting^ Text {
String^ get() { ... }
void set(String^ value) { ... }
}
</code>

but on many cases it is even less code:

<code language="C++/CLI">
property String^ Text;
</code>

will automatically allocate the backing storage and implement getters and
setters.

The biggest coding benefit comes with implicitly dereferenced access and
interop:

<code language = "C#">
class X : IDisposable {
private Object oLock = gcnew Object;
private Mutex mtx = gcnew Mutex(...);

public void Dispose() {
mtx.Dispose();
}

public void f() {
lock(oLock) {
using (FileStream fs = gcnew FileStream(".....", ....))
using (...) {
...
}
}
}
};
</code>

<code language = "C#">
class X {
Object oLock;
Mutex mtx(...);
public:
void f() {
msclr::lock(%oLock)
FileStream fs(".....", ....));
... other implicitly dereferenced things ...
...
}
};
</code>

C++/CLI has many advantages here:
1) It is not necessary to implement IDisposable yourself, the compiler does
this for you.
2) Notice that C#'s lock is a language construct while msclr:lock is a heper
class that comes with C++/CLI. It is easy to implement your own helpers and
even the standard one has a feature, that you will miss in C#:

msclr::lock(%oLock, 2000);
Acquires the lock with a 2 second timeout.

Marcus Heege
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jay Sartoris | last post by:
Hi, I'm adding a node to my XML document using DOM. When I serialize it, I lose my comments that are above my root node. I've created an OutputFormat obect and set the setOmitComments(false)...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
19
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback...
2
by: Landen | last post by:
I am wanting to replicate a linux feature that I can't seem to find anywhere in windows as an addin or program. If anyone is familiar with linux, if you right click on a folder or file, you get the...
0
by: Jordi | last post by:
I'm making a feature-file to train a Neural Network, but now that I've added a new feature, the output becomes corrupted. The output is as follows: 3000 25 1_002858 5 0 0 0 0 2 2 0 0 0 0 2 2 0 0...
3
by: SAL | last post by:
Is there a setting in VS.net 2003 IDE that I can change, so when I add a PANEL to my ASP.net page and place controls on the PANEL itself, it will allow me to move the controls on the Panel where I...
15
by: Dan Henry | last post by:
I have run across functions in the Linux kernel's MTD driver that have me scratching my head a bit. The functions have the general form: extern int bar(size_t len, size_t *retlen, unsigned char...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.