Wednesday, February 13, 2008

Upgrading your device solutions to Visual Studio 2008 and the .NET CF 3.5

As the title says upgrading your pre 2008 device solutions to Visual Studio 2008 and to run under the .NET CF 3.5 is a two step process. This is because Visual Studio 2008 supports multi-targeting.

By default when you upgrade your VS 2005 projects to VS 2008 they continue to target the .NET Framework 2.0. This is true for both desktop and devices. This article quickly talks about how you target the new frameworks after conversion.

1. Open your VS 2005 solution in VS 2008. The conversion wizard will load, simply run though this.



2. This particular solution contains device projects as well as desktop projects.

3. As you can see, after the project has been converted, it is still compiled against the CF 2.0.



4. In VS 2008 there is a new menu option labeled "Upgrade Project" (among others) under Project or the same option can be accessed under the context menu by right clicking the project.

NOTE: This new option is only visible to device applications.

Clicking it will upgrade your Compact Framework 2.0 application to compile against the Compact Framework 3.5.



5. Clicking the "Upgrade Project" menu option will prompt you to continue.



Once you have clicked Yes, the process is very quick and does indeed upgrade your device application to compile against the CF 3.5.



6. After doing the above you will notice the "Upgrade Project" menu option will disapear from the project context and main menus.



Although this post is mainly about devices I thought I'd mention converting your desktop applications from .NET Framework 2.0 to .NET Framework 3.5 is slightly different. There is no "Upgrade Project" menu option for desktop projects, instead you have to use the muli-targeting support features under project properties to target the .NET Framework 3.5.

9 comments:

Unknown said...

Hello Simon;

I really appreciate it if you can shed some light on this issue i'm encountering after i upgrade my device project (which is a Control library that also serves as a class library for some classes) to CF 3.5.

I get the following error at build time.
"genasm.exe(1) : error There was an error initializing . Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified."

My version of VS is 2008 Professional Edition v9.0.21022.8 RTM.

I also use the following in my control library project.
1. An .xmta file to make by 'base form' 'visually-inheritable' (yes, i use Visual Forms Inheritance) in another assembly that references this.
2. At least one Generic class that happens to be public
3. SQL Server CE 3.5

I mentioned the above, since this combination (or a subset of it) has caused the said problem in pre-release versions of both VS 2008 and CF 3.5!

This has been a serious deterrant for us to move from CF 2.1 to 3.5, unfortunately.

Regards, Udara

Anonymous said...

Same problem here.

Ben

Carsten said...

Hi Simon,

I got the same problem as well, same versions, same stuff.

Greedings

Carsten

Simon Hart said...

Chaps, I'm looking into this.

drozd said...

Hi Simon,

I too had a problem with building an upgraded project. I was using a .xmta file for visual inheritance.

I managed to get past it by simply deleting the .xmta file.

The project builds now and the problem with designing inherited forms doesn't come up. Maybe the DesktopCompatible attribute is no longer needed..

Anyway, Udara, Carsten - you could try what I've done - it might work.

Kind regards,
MichaƂ

Barrett said...

Had the same problem. I havent tried this yet but...
See comment #12

http://www.cooldevelopers.com/program/130/16130-genasm-error-message-when-adding.html

It probably will work since I currently use an .XMTA with DesktopCompatible in a dll that builds in my project without any errors.

Hope this helps someone. (and sorry to revive an old thread)

BarrettLee

Anonymous said...

I've solved commenting the code that produces the error, building the projet to generate the xmta dll and uncommenting the code. Preserve your dll for prevent a delete when cleaning your solution

Unknown said...

Hey there Guys, I was getting the same problem when adding an XMTA file to a Smart Device application. All I did to solve the problem was change the "Build Action" against the XMTA file from "None" to "Embeded Resource"

Anonymous said...

It took me a long time to search on the web, only your site explain the fully details, bookmarked and thanks again.

- Kris