473,387 Members | 1,530 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,387 software developers and data experts.

Conversion from 2003 to 2005 just too hard

I've been trying all morning to convert my 2003 project (managed) to 2005
(/clr since I have both managed and unmanaged code). I'm guessing I have
tens of thousands of lines of code to change. Did a lot of converting '__gc'
to 'ref', converting '*' to '^', converting 'new' to 'gcnew'. Of course this
can't be done with a blanket replace, as my code has both managed and
unmanaged segments. Thus I have to do them one-by-one. Also, things are
missing. Like Form no longer has a Bounds property anymore (or at least if I
try to use it I get an 'it doesn't exist' error, which is a line that
compiled just fine in 2003). I can't have private virtual function even
though they were fine in 2003 (ok, i can see why they have to be protected).
In short, it's kind of exasperating to have to deal with an upgrade that
isn't even remotely backwards compatible (not even with old syntax switched
on)...

But, even after willing to do all of these changes, I now think I should
stop, having run into the Graphics class.

Graphics methods such as DrawPolygon() apparently no longer compile. The
only versions given are the ones using old syntax format for the required
__gc Points[] array. No /clr compatible overload of this function is given
(at least not in the look-ahead pop-up that comes up for DrawPolygon). So
how does one now draw a Polygon with the Graphics class now?

It's looking more and more that if you started in 2003 one should
(unfortunately) stay in 2003. Starting a project in 2005 might be good, but
converting is extremely difficult and prone to lots of erros. And even the
conversion I did into an old syntax 2005 version now returns with an
exception error it didn't have in 2003.... : (

Why didn't MS write a conversion tool? Sure it probably couldn't do
everything, but it could do the most obvious stuff. Like:

(1) identify '__gc' stuff and 'ref' it (note this doesn't work as a blanket
edit replace since '__gc' is also used to define other stuff, like arrays)
(2) replace appropriate '*' with '^', replace appropriate 'new' with
'gcnew', replace the '__' words with the new syntax versions (e.g.,
'__delegate' with 'delegate')
(3) make appropriate private virtual methods protected
(4) change abstract classes to the new syntax
(5) redefine arrays with the new 'array' syntax
(6) identify old methods that no longer works and put in the new syntax
(e.g., replace MakePolygon() code lines with the new syntax, and do this
will all such methods which have changed format)
(7) etc.

I've seen compiler errors that say stuff like "you did X, use Y instead".
Why doesn't the compiler give an option to make those changes FOR YOU?

I think 2005 is way too different from 2003 to call it an 'upgrade'. It's
basically incompatible with 2003 if one decided to use Managed C++...

[==P==]
Nov 17 '05 #1
11 1685
I understand your pain, Peter - but for about an year and a half, it was
pretty obvious that investing time in MC++ code would not be such a smart
thing to do, ever since Herb Sutter talked about C++/CLI a few PDCs ago.
Every time someone had asked if it was worthwhile to try Managed C++ (old
syntax), I had explicitly told them that my advice would be to wait for
2005. I did this in spite of the fact that this would probably affect the
sales of my book (which targetted the old syntax).

On a related note, this might help some of us understand why a lot of VB6ers
were pissed when VB.NET came out, it wasn't an upgrade, it was a whole new
language/syntax etc.

On another related note, I vaguely remember Stan Lippman saying that he was
working on an old syntax to new syntax converter - but I am not sure that he
ever got around to finishing that.

--
Regards,
Nish [VC++ MVP]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:e3**************@TK2MSFTNGP14.phx.gbl...
I've been trying all morning to convert my 2003 project (managed) to 2005
(/clr since I have both managed and unmanaged code). I'm guessing I have
tens of thousands of lines of code to change. Did a lot of converting
'__gc' to 'ref', converting '*' to '^', converting 'new' to 'gcnew'. Of
course this can't be done with a blanket replace, as my code has both
managed and unmanaged segments. Thus I have to do them one-by-one. Also,
things are missing. Like Form no longer has a Bounds property anymore (or
at least if I try to use it I get an 'it doesn't exist' error, which is a
line that compiled just fine in 2003). I can't have private virtual
function even though they were fine in 2003 (ok, i can see why they have
to be protected). In short, it's kind of exasperating to have to deal with
an upgrade that isn't even remotely backwards compatible (not even with
old syntax switched on)...

But, even after willing to do all of these changes, I now think I should
stop, having run into the Graphics class.

Graphics methods such as DrawPolygon() apparently no longer compile. The
only versions given are the ones using old syntax format for the required
__gc Points[] array. No /clr compatible overload of this function is given
(at least not in the look-ahead pop-up that comes up for DrawPolygon). So
how does one now draw a Polygon with the Graphics class now?

It's looking more and more that if you started in 2003 one should
(unfortunately) stay in 2003. Starting a project in 2005 might be good,
but converting is extremely difficult and prone to lots of erros. And even
the conversion I did into an old syntax 2005 version now returns with an
exception error it didn't have in 2003.... : (

Why didn't MS write a conversion tool? Sure it probably couldn't do
everything, but it could do the most obvious stuff. Like:

(1) identify '__gc' stuff and 'ref' it (note this doesn't work as a
blanket edit replace since '__gc' is also used to define other stuff, like
arrays)
(2) replace appropriate '*' with '^', replace appropriate 'new' with
'gcnew', replace the '__' words with the new syntax versions (e.g.,
'__delegate' with 'delegate')
(3) make appropriate private virtual methods protected
(4) change abstract classes to the new syntax
(5) redefine arrays with the new 'array' syntax
(6) identify old methods that no longer works and put in the new syntax
(e.g., replace MakePolygon() code lines with the new syntax, and do this
will all such methods which have changed format)
(7) etc.

I've seen compiler errors that say stuff like "you did X, use Y instead".
Why doesn't the compiler give an option to make those changes FOR YOU?

I think 2005 is way too different from 2003 to call it an 'upgrade'. It's
basically incompatible with 2003 if one decided to use Managed C++...

[==P==]

Nov 17 '05 #2
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in
news:e3**************@TK2MSFTNGP14.phx.gbl:
Graphics methods such as DrawPolygon() apparently no longer compile.
The only versions given are the ones using old syntax format for the
required __gc Points[] array. No /clr compatible overload of this
function is given (at least not in the look-ahead pop-up that comes up
for DrawPolygon). So how does one now draw a Polygon with the Graphics
class now?


IntelliSense (the look-ahead popup) can only work in one C++ managed
code syntax: either the old managed C++ syntax or the new C++/CLI
syntax. When you have projects in the solution that have a mix of both,
IntelliSense gets confused. (In reality, in some situations it may also
get confused if you started with old syntax and set it to new syntax).

If you would like to get IntelliSense on the prototypes of some
functions in the new syntax when you have some of those "mixed-syntax"
solutions, you can just create a new solution that has only one project
that's compiled with the new syntax. IntelliSense in that project will
show exactly what you want to see: prototypes in the new syntax only.
You can use that as help when writing code in the "mixed-syntax"
solutions.

I hope this helps.

Thanks,
--
Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.
Nov 17 '05 #3
Peter Oliphant wrote:

Graphics methods such as DrawPolygon() apparently no longer compile.
The only versions given are the ones using old syntax format for the
required __gc Points[] array. No /clr compatible overload of this
function is given (at least not in the look-ahead pop-up that comes
up for DrawPolygon). So how does one now draw a Polygon with the
Graphics class now?


IntelliSense is not and has never been the reference to say what is valid
and what is not, you shouldn't rely on it. The reference is :
1) MSDN.
2) The compiler error messages.

If IntelliSense doesn't give what you think is the correct sytnax, just
write it by hand and try to compile it.

This does compile with /clr (it's a copy-paste from MSDN documentation) and
it works correctly in the Paint handler of a WinForm :

Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
Point point1 = Point(50,50);
Point point2 = Point(100,25);
Point point3 = Point(200,5);
Point point4 = Point(250,50);
Point point5 = Point(300,100);
Point point6 = Point(350,200);
Point point7 = Point(250,250);
array<Point>^ curvePoints =
{point1,point2,point3,point4,point5,point6,point7} ;

e->Graphics->DrawPolygon( blackPen, curvePoints );
//e is a valid PaintEventArgs

Arnaud
MVP - VC
Nov 17 '05 #4
I wish there was a way to change *part* of my source to /clr while leaving
the rest as old syntax. I know this is an unreasonable desire, since it
would have problems in one section if it refered to something in another
section (e.g., it would be weird if GC_Class^ were used in one place and
GC_Class* in another).

My problem is that for me to change it to /clr syntax I have to change *all*
of my source code to be compliant for it to compile successful. In my case
that looks like it would take changing literally thousands if not tens of
thousands of lines of code (and I only started writing this code 6 weeks
ago, I tend to be verbose...lol). Thus, its a daunting task that must work
in its entirety or not at all.

And I ran into a 'road block' ala a problem with methods like the Graphics
class method DrawPolygon(). According to MSDN on-line, this Graphics class
method ONLY takes Point __gc[] as a parameter for the vertex points list of
the polygon to be formed, which is old syntax format. No /clr compliant
version appears to exist. I can't find any new version in MSDN on-line
documentation, so it looks like DrawPolygon is no longer available.

I doubt that this is the case, some new version of DrawPolygon probably does
exist, or some way to still use the old version under /clr (I know it
doesn't work without some change, the compiler complains about anything of
the form Point _gc[]'), but how do I find out the details to it? Will a
method that has a parameter of the form "Point __gc[] point" work if I give
it something defined like this:

array<Point^>^ point

[==P==]
"Arnaud Debaene" <ad******@club-internet.fr> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
Peter Oliphant wrote:

Graphics methods such as DrawPolygon() apparently no longer compile.
The only versions given are the ones using old syntax format for the
required __gc Points[] array. No /clr compatible overload of this
function is given (at least not in the look-ahead pop-up that comes
up for DrawPolygon). So how does one now draw a Polygon with the
Graphics class now?


IntelliSense is not and has never been the reference to say what is valid
and what is not, you shouldn't rely on it. The reference is :
1) MSDN.
2) The compiler error messages.

If IntelliSense doesn't give what you think is the correct sytnax, just
write it by hand and try to compile it.

This does compile with /clr (it's a copy-paste from MSDN documentation)
and it works correctly in the Paint handler of a WinForm :

Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
Point point1 = Point(50,50);
Point point2 = Point(100,25);
Point point3 = Point(200,5);
Point point4 = Point(250,50);
Point point5 = Point(300,100);
Point point6 = Point(350,200);
Point point7 = Point(250,250);
array<Point>^ curvePoints =
{point1,point2,point3,point4,point5,point6,point7} ;

e->Graphics->DrawPolygon( blackPen, curvePoints );
//e is a valid PaintEventArgs

Arnaud
MVP - VC

Nov 17 '05 #5
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I wish there was a way to change *part* of my source to /clr while leaving
the rest as old syntax. I know this is an unreasonable desire, since it
would have problems in one section if it refered to something in another
section (e.g., it would be weird if GC_Class^ were used in one place and
GC_Class* in another).

My problem is that for me to change it to /clr syntax I have to change
*all* of my source code to be compliant for it to compile successful. In
my case that looks like it would take changing literally thousands if not
tens of thousands of lines of code (and I only started writing this code 6
weeks ago, I tend to be verbose...lol). Thus, its a daunting task that
must work in its entirety or not at all.

And I ran into a 'road block' ala a problem with methods like the
Graphics class method DrawPolygon(). According to MSDN on-line, this
Graphics class method ONLY takes Point __gc[] as a parameter for the
vertex points list of the polygon to be formed, which is old syntax
format. No /clr compliant version appears to exist. I can't find any new
version in MSDN on-line documentation, so it looks like DrawPolygon is no
longer available.

I doubt that this is the case, some new version of DrawPolygon probably
does exist, or some way to still use the old version under /clr (I know it
doesn't work without some change, the compiler complains about anything of
the form Point _gc[]'), but how do I find out the details to it? Will a
method that has a parameter of the form "Point __gc[] point" work if I
give it something defined like this:

array<Point^>^ point


Yes, they're exactly the same type, one spelled in the old syntax, the other
in the new syntax.

-cd

Nov 17 '05 #6
Peter Oliphant wrote:

And I ran into a 'road block' ala a problem with methods like the
Graphics class method DrawPolygon(). According to MSDN on-line, this
Graphics class method ONLY takes Point __gc[] as a parameter for the
vertex points list of the polygon to be formed, which is old syntax
format. No /clr compliant version appears to exist. I can't find any
new version in MSDN on-line documentation, so it looks like
DrawPolygon is no longer available.

Have you read and try the example I gave you?

And of course, the new syntax is documented on MSDN :
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

The C++ syntax has changed, the BCL contents hasn't changed that much...

Arnaud
MVP - VC
Nov 17 '05 #7
"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote
the form Point _gc[]'), but how do I find out the details to it? Will a
method that has a parameter of the form "Point __gc[] point" work if I
give it something defined like this:

array<Point^>^ point


Yes, they're exactly the same type, one spelled in the old syntax, the
other in the new syntax.

Umh, unless I'm missing something these don't match because you
have another level of indirection here.

I guess it should be array<Point>^ point (I'm too lazy to look it up, but
I would design Point as a value type).

Otherwise it should have been
Point* [] point
in the first place.

-hg

Nov 17 '05 #8

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I understand your pain, Peter - but for about an year and a half, it was
pretty obvious that investing time in MC++ code would not be such a smart
thing to do, ever since Herb Sutter talked about C++/CLI a few PDCs ago.
Every time someone had asked if it was worthwhile to try Managed C++ (old
syntax), I had explicitly told them that my advice would be to wait for
2005. I did this in spite of the fact that this would probably affect the
sales of my book (which targetted the old syntax).


Are you telling us as an MVP, that you suggest not to use a whole product of
microsoft just because
you are familiar with the MS's inconvenient way of improving unlovely
products?

Isn't it pain in the ass situation to suffer a monololists stategies?
downward compatibility should be
a development goal not an unloved duty.

..NET rocks and MS did a good job but they should continue their work and
improve update stragegies.

Greets, Sebastian Dau
Nov 17 '05 #9
You're correct, that DrawPolygon is defined and up-to-date on the link you
provided (thanks!):
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx
But, I kind of ran into a 'decoy' page, ala this other page in on-line MSDN:

http://msdn.microsoft.com/library/de...lygontopic.asp

Any hints as how to find the most recent and up-to-date pages on MSDN? You
can see how I was a bit confused having only found the link I gave above,
and IntelliSense 'said' the same thing... : )

[==P==]
"Arnaud Debaene" <ad******@club-internet.fr> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl... Peter Oliphant wrote:

And I ran into a 'road block' ala a problem with methods like the
Graphics class method DrawPolygon(). According to MSDN on-line, this
Graphics class method ONLY takes Point __gc[] as a parameter for the
vertex points list of the polygon to be formed, which is old syntax
format. No /clr compliant version appears to exist. I can't find any
new version in MSDN on-line documentation, so it looks like
DrawPolygon is no longer available.

Have you read and try the example I gave you?

And of course, the new syntax is documented on MSDN :
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

The C++ syntax has changed, the BCL contents hasn't changed that much...

Arnaud
MVP - VC

Nov 17 '05 #10
The offline MSDN collection that's installed with VS.NET 2005 is quite
up-to-date too!

--
Regards,
Nish [VC++ MVP]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
You're correct, that DrawPolygon is defined and up-to-date on the link you
provided (thanks!):
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx


But, I kind of ran into a 'decoy' page, ala this other page in on-line
MSDN:

http://msdn.microsoft.com/library/de...lygontopic.asp

Any hints as how to find the most recent and up-to-date pages on MSDN? You
can see how I was a bit confused having only found the link I gave above,
and IntelliSense 'said' the same thing... : )

[==P==]
"Arnaud Debaene" <ad******@club-internet.fr> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
Peter Oliphant wrote:

And I ran into a 'road block' ala a problem with methods like the
Graphics class method DrawPolygon(). According to MSDN on-line, this
Graphics class method ONLY takes Point __gc[] as a parameter for the
vertex points list of the polygon to be formed, which is old syntax
format. No /clr compliant version appears to exist. I can't find any
new version in MSDN on-line documentation, so it looks like
DrawPolygon is no longer available.

Have you read and try the example I gave you?

And of course, the new syntax is documented on MSDN :
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

The C++ syntax has changed, the BCL contents hasn't changed that much...

Arnaud
MVP - VC


Nov 17 '05 #11
> If you would like to get IntelliSense on the prototypes of some
functions in the new syntax when you have some of those "mixed-syntax"
solutions, you can just create a new solution that has only one project
that's compiled with the new syntax.
Considering my application has ten's of thousands of lines of old syntax
code, this statement reminded me of the Larson cartoon where a careful study
of a scientist blackboard reveals the words with a pointer that says 'and a
*miracle* happens here"...LOL

Seriously, I really think the new syntax is great, just conversion to it
from the old syntax is tough. I started a new project from scratch
(different application), and I'm loving the new syntax! But I'm also trying
to convert an existing six-week old project from old syntax to new syntax,
and I'm NOT loving that... :)

[==P==]

"Tarek Madkour [MSFT]" <ta****@online.microsoft.com> wrote in message
news:Xn*****************************@207.46.248.16 ... "Peter Oliphant" <po*******@RoundTripInc.com> wrote in
news:e3**************@TK2MSFTNGP14.phx.gbl:
Graphics methods such as DrawPolygon() apparently no longer compile.
The only versions given are the ones using old syntax format for the
required __gc Points[] array. No /clr compatible overload of this
function is given (at least not in the look-ahead pop-up that comes up
for DrawPolygon). So how does one now draw a Polygon with the Graphics
class now?


IntelliSense (the look-ahead popup) can only work in one C++ managed
code syntax: either the old managed C++ syntax or the new C++/CLI
syntax. When you have projects in the solution that have a mix of both,
IntelliSense gets confused. (In reality, in some situations it may also
get confused if you started with old syntax and set it to new syntax).

If you would like to get IntelliSense on the prototypes of some
functions in the new syntax when you have some of those "mixed-syntax"
solutions, you can just create a new solution that has only one project
that's compiled with the new syntax. IntelliSense in that project will
show exactly what you want to see: prototypes in the new syntax only.
You can use that as help when writing code in the "mixed-syntax"
solutions.

I hope this helps.

Thanks,
--
Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.

Nov 17 '05 #12

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

Similar topics

1
by: Peter Oliphant | last post by:
At one point I started a thread about how hard it is to convert 2003 Managed C++ code to 2005 /clr C++ code, and said it was too hard. Well, now that I've been doing it for a while, it isn't really...
9
by: Vince | last post by:
Hi all, I am trying to convert a VB 6 application to VB.NET 2005 using the wizard. It has over 20 forms and I've used Option Explicit everywhere, hence variables are properly declared and used....
11
by: Neil | last post by:
We are running SQL 7, using Access 2000 as a front end. Our network person is wanting to migrate to Windows 2003 (we're currently on Windows 2000), and wants to know if we should migrate to SQL...
2
by: GW | last post by:
After the conversion and fixing some errs VS2005 threw, project ran OK. Opened xxx.vbproj file after the conversion to VS2005 from VS2003. Changed (usng wordpad) ../msbuild/2003 to 2005...
5
by: matthewtec | last post by:
I realize there are probably many discussions on these two... whether to get now or wait or yadda yadda yadda. My question is that I can continuing training on visual studio.net 2003, and...
11
by: Maximus | last post by:
Hi all, Has anyone been able to reterive the gradient selection colors used in outlook 2003? Basically, I have a grid showing a list of records and my client wants the selected row to have the...
5
by: JT | last post by:
Hi, I'm not sure where the problem is, but I think it's related to the .pdb file. I had a class library created in VS 2003 and decided to convert it to a VS 2005 project/solution. It seemed to...
4
by: Coleen | last post by:
Hi All :-) I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors. I found this site to help walk me through the...
5
by: Randy | last post by:
I've converted a VS 2003 project to VS 2005. I have one utility class that it put in the APP_CODE directory. When I try and compile I'm getting this error... Error 1 The type or namespace name...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.