[RESOLVED]Migrate from Web Matrix to Visual Studio 2013

SQL programmer just getting into web-based development.

Wrote a basic CRUD web app using Web Matrix with the understanding that it would run under Visual Studio.

Launched Visual Studio & got numerous error messages when I tried to run the app – mostly of the type "… Are you missing a reference?".

Read a post here that seemed to imply that I might need to manually add "Using …" statements to include libraries that Web Matrix automatically includes, but that VS doesn’t.

As one of my errors was on a line that included a String.IsNullorEmpty() call, I tried adding "@using System.String;" to the top of my code page.

This resulted in the addition of 6 warnings of the type " … has dependencies on a version of .Net Framework that is higher than the target…"

My question: is there documentation somewhere that details the steps needed to accomplish a successful migration from Web Matrix 3 into VS 2013 for Web?

WebMatrix runs under Visual Studion, without a hiccup.

There are some benefits of having both WM and VS working together, for instance in a multiple monitor environment. My suggestion is to figure out what went wrong.

Created a new site from the WM startersite template and create a test environment.  Open it in VS from WM.

EvanFlink

is there documentation somewhere that details the steps needed to accomplish a successful migration from Web Matrix 3 into VS 2013 for Web?

You should just use the File » Open » Web Site option in Visual Studio, navigate to your WebMatrix app and Bob’s your uncle. From what you describe, you must have taken a different approach to cause so many issues.

Hi Mike,

Well Robert would appear to be my father’s least-liked brother, as he’s giving me all kinds of trouble.
Laughing

A screenshot or image attachment would be better, but here’s a mockup up of the problem as it appears while in VS 2013.

code from my cshtml file:

if(String.IsNullOrEmpty(Co.CO_Abbrev_Name))
            { return Co.CO_Name; }

error message in VS 2013 reads as follows:

"One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?"

This same message appears when I hover the cursor over the keyword ‘String’ in the code above. When I click on ‘Goto Definition (F12)’ in the right-click menu, it shows me namespace System in mscorlib.dll. Do I have to somehow manually include this dll for
my app to compile?

Just not familiar enough with the process to know what to do next.

Thanks

Since you’re saying, you’re a SQL developer and getting into the web-development. Let me tell you, ASP.NET is based on C# (VB.NET version is also allowed, Visual C++ might also be an option, since .NET framework can be programmed using Visual C++; but is
very rare). So, these evers are generally coming out from the C#. 

A reference in C# is a declaration to include the Assembly file. As you’re saying the posts tell you to include the files, using a "Using" statement they’re right! Then you get into another problem. So, I would ask you to stop here! And go to the MSDN documentations
for the C#. Since ASP.NET is based on C# (sorry for saying this sentence again), you can learn the C# itself and then ASP.NET won’t cause any trouble to you.

However, the basic assemblies, are automatically included in the .cshtml files and you don’t have to write the using statements for the commonly used namespaces. There is no tough rule in that file. The one you use in WebMatrix (as found in StarterSite template).
But still you can use that line. But since the Visual Studio has an option for Web Forms, MVC etc, the application you might use, would either be an aspx file or a .cs file where you’re required to stick to the plans and the rules. So these applications might
give you a tough time. 

Going into them would require you to have basic understanding of the C# itself. 

http://msdn.microsoft.com/en-us/library/618ayhy6.aspx (C# Reference)

http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx (C# Tutorials)

Good luck!

It looks like Co.CO_Abbrev_Name is a dynamic type. Try casting it to a string before attempting any string methods on it:

if(String.IsNullOrEmpty((string)Co.CO_Abbrev_Name))
            { return null; }

Hi Mike,

Keep in mind that all this code worked as expected in the Web Matrix environment. Do I need to do explicit typecasting when working with the same code in VS?

If so that sure limits the portability of the code & makes me wonder what the point of supporting Web Pages in VS might be.

Next – is there a way to attach screenshots to these messages? A screenshot of the VS window would sure provide more (hopefully helpful) info than my manual synopsis, and might make obvious what the problem actually is.

Thanks again to you and the other responders.

Yes, just attach the images from the editor. It is alongwith the Big Yellow smiley. That would be a good thing to share. You might need to upload your image on some image storage service provider and then post the link to that image too. 

Hi Afzaal,

Thanks for your replies. I have some familiarity with C# (and some with Java, which works similarly) but would still consider myself something of a novice with C#.

I took you advice & signed up with an image hosting service & so have provided a screenshot of code & error messages. This code builds & works fine in the Web Matrix environment. I don’t remember if I checked to see what the return type was when I wrote
it, but the function works so I’m assuming that the type is string.

Note that the last error message was based on my wild guess that I needed to add an ‘include System.String’ directive. That has been removed now.

Any comments or input based on what you can see?

 Screenshot of Web Matrix Project in VS 2013 Express for Web environment

edit: hmm – I see the image description, but not the actual image.

2nd edit: change from image to link – at least you can see the screenie now.

Does the code still work in WebMatrix?

Yes it does – just fired it up & ran it.

To address your earlier comment more directly – I launched VS by clicking the ‘Launch’ button on the Home ribbon of WM.

When I tried opening the project using File – Open Web Site, VS says (paraphrased) " the site localhost:44861 is using a newer version of .Net (4.0). The project is targeting ASP.NET2.0; if not configured some features may make incorrect assumptions …. 
Would you like the site to be configured for use with ASP.NET 2.0?"

I answered ‘No’ and am now getting additional error messages like this:

Error    4    Feature ‘implicitly typed local variable’ cannot be used because it is not part of the ISO-2 C# language specification    c:UsersEvanDesktopDDC_Inc_WebformApp_CodeDDCHelpers.cshtml    54    9    DDC_Inc_Webform

In WM, under Site-Settings – Select .Net Framework Version – it says .Net 4 (Integrated), & under ASP.Net Web Pages it says: 2.0.30506.0 Version is up to date.

Is this a problem?

Can you clarify what version of VS you are using?

Installed this in approx. June 2014 (ie, a couple of months ago)

From the ‘About’ dialog:

Microsoft Visual Studio Express 2013 for Web
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.50938

Installed Version: WD Express

Team Explorer for Visual Studio 2013   06156-004-0437007-02394
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06156-004-0437007-02394
Microsoft Visual Basic 2013

Visual C# 2013   06156-004-0437007-02394
Microsoft Visual C# 2013

ASP.NET and Web Tools   2013.2.50425
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Windows Azure Web Sites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.1.20409.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.1
Provides common services for use by Azure Mobile Services and Windows Azure Tools.

NuGet Package Manager   2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   12.0.30919.1
Microsoft SQL Server Data Tools

What I would do under the circumstances is to create a new site using the Empty Site template, and then keep only the web.config file (and anything in the bin folder). Then copy across all of your existing code. You can use File Explorer to copy the existing
files across. Make sure it runs in WM then try opening that directly from within VS.

Alright – will give that a try

Thanks Mike – that, in typical "roll it up the hill & see if does it again" fashion, worked.

Created a new empty site, re-connected my databases, added in js, css, images, shared & index pages, testing as I went, then finally said screw it & dumped all remaining pages in due to the tediousness.

Built on first try & ran! Nice part was that, in VS, I found a couple of unrelated errors.

Thanks much & thanks also for your web site, which I have referred to, & got good info from, several times while working on this project.

Best Regards

Leave a Reply