Tag Archives: Visual Studio

VS 11 Experience

Today I decided to give it a go and install VS 11 Developer Preview (off the USB key I got from BUILD) onto my production machine. Whoa, Steve, that could be risky!!

Yeah, it could, but sometimes you need to live life on the edge. As much as a geek can.

There aren’t a ton of options when installing. The installer looks.. “beautiful” compare to other Visual Studio installers. It installed a few things, then reboot, then some more, then it was done. Easy. But of course, it installed SQL Express (Denali CTP3) which I really didn’t want to install since I already have 2008 R2 developer on my machine. Maybe in the advanced install I could have disabled it, but I didn’t dig through it all. Anyways, I just turned the service off and set it to manual start.

VS 11 is nice. Seems faster. Cleaner. Crisper. I LOVE the code clone feature. Found some good info there. I like the new TFS design (the work items, etc look nicer – almost a fat client version of the new TFS server and TFS azure experience).

The big app we work on compiled and ran, which was good. I didn’t try .NET 4.5 yet, that might be for another day. One thing that does stink about the dev preview is that you lose all your add ons. The VS productivity tools are baked in (at least some? I didnt try them all). But things like Resharper, etc aren’t there so you might be “missing” some things you are used to.

The solution file of the project changed on me, since I opened up a VS 2010 sln file. It added some comments and rearranged some things, but after I closed VS 11 and saved everything, I opened in VS 2010 and it still worked. Checked into source control and other devs with just VS 2010 opened it and it worked, etc. So MSFT wasn’t lying.. backward compatible!

Excited to dig into it more and for the future versions.

Visual Studio 2010 Productivity Power Tools

One nice thing released for VS2010 recently is the “Productivity Power Tools”. If you are using VS2010 I would recommend installing it.

Once installed, you can see the options under Tools->Options->Productivity Power Tools

 

image

One feature I really like is the “Fix Mixed Tabs” feature.

image

When you open a code file it will analyze and tell you if need to “Tabify” – convert spaces to tabs, the old developers argument of tabs vs spaces solved. BTW, they should be tabs!

Check out the tools and learn the other features, there are some good things in there to help your code and get around in VS2010.

Visual Studio 2010: Console App, Where is my System.Web?

If you create a new Console App in Visual Studio 2010, and you want to reference System.Web, you might start scratching you head. Why?

Looks like Visual Studio 2010 creates new Console Apps targeting the .NET Framework 4 Client Profile instead of the .NET Framework 4. Why? No idea, but you can change it and then reference System.Web

You can change the setting by going to Properties on your project, then the Application tab, and changing the drop down of the Target Framework to .NET Framework 4

image

Visual Studio 2010: Adding a Web Reference

In previous versions of Visual Studio, you could just right click on a project and choose “Add Web Reference” to add a reference to a asmx web service. In Visual Studio 2010, when you right click, you will see “Add Service Reference”… similar, but not the same. If you reference an asmx you will get some weird objects back in your proxy web service object, each method with Request/Response at the end. You may want this, you may not. If you want to get the legacy web reference back, here is what you need to do.

Right Click on a project, Add Service Reference, then click on Advanced, the Add Web Reference. Then you will be able to add your good old asmx reference like you used to in earlier versions of Visual Studio.

image

Why isn’t there a Web 2.0 Ajax Visual Studio?

Was thinking about this today. You can now write Word docs, Excel spreadsheets, Powerpoint presentations and the like all online (Google Docs, Zoho, etc, etc). You can record video straight to websites through your webcam, you can video conference directly through the web.

Visual Studio in the Cloud:

Why can’t you code directly into the web?

I would like to see an app that lets you create a new .NET project through a web interface, reference dll’s if you need to (upload them to your “space”) and then go about creating code, Intellisense through Ajax, you hit compile, it sends it off to the server, compiles, and gives you a result. You can then browse to your exe or your new website and view the results.

No need for a bulky IDE installed on your computer, no worries about dependencies, etc. You could code C#/VB.NET on linux and a mac with no need for mono (although you couldn’t run the exe’s – it would be the most beneficial for web apps)

You could target different versions of the framework, use new features if you wanted, all that. Heck why not have the same thing for your database. mySQL already has it with phpadmin and all the other tools, you can query and do whatever you need to through the web. Where are the offerings like this for MSFT products? Maybe I just don’t know about them.

There is CodeIDE – http://www.codeide.com/ but it is limited in languages and options. I want to see more of a full fledged Visual Studio IDE in the browser. Why? Because I want to be able to fire up a computer and just go to work, no installing, no waiting, no upgrading.

I can already see it now, Adobe Air IDE’s you can run on your desktop and sync up source code to the online IDE.

One feature built right in to this “online IDE” would be source control, revision history, etc.

I might not be possible right now, but I say give it a few years, and we will see a product like this come out, and I can’t wait.

Visual Studio 2005/2008 Web Application Projects: Profile Class Auto Generation Workaround

I have been doing some coding with VS2008, and have been playing with the .NET Membership, Role, and Profile providers. I don’t use "Web Sites" when I create projects, instead I use "Web Applications" – what is the difference? Web Sites don’t really act like a first class application, there are some weird things with references, the bin directory, etc. Web Application act like a console app, or windows form app, the way you can reference assemblies, etc. There are a ton more differences I am sure, but those are the ones that stand out for me.

Now, with the Profile stuff in ASP.NET, you can use a Login control, and CreateUserWizard control, and then hook up your site to a SQL backend using the ASP.NET Membership provider. Everything works great. But you can also add custom properties (ex: First Name, Last Name, etc) to your user’s "Profile". You add these settings in the Web.Config

<profile enabled="true">
    <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
        <group name="Address">
            <add name="Address1" type="string"/>
            <add name="Address2" type="string"/>
            <add name="City" type="string"/>
            <add name="State" type="Int32"/>
            <add name="Country" type="Int32"/>
            <add name="PostalCode" type="string"/>
        </group>
        <add name="PhoneNumber" type="string"/>
    </properties> 
</profile>

and then when you build your project, Visual Studio is supposed to auto create a class behind the scenes with those properties. This works fine if you use a "Web Site", but fails to do so when you have a "Web Application"

In VS2005, there was an add in you could install that would auto create this class on build, and there is one as well for VS2008 – Web Profile Builder.

You can use the Web Profile Builder which just creates a class for you, or you can create your own, or you can just code around it, like this:

CreateUserWizard cuwWiz = (CreateUserWizard)lgnView.FindControl("CreateUserWizard1");

ProfileBase p = ProfileBase.Create(cuwWiz.UserName, true);

p.SetPropertyValue("FirstName", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtFirstName")).Text);
p.SetPropertyValue("LastName", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtLastName")).Text);

p.GetProfileGroup("Address").SetPropertyValue("Address1", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtAddress1")).Text);
p.GetProfileGroup("Address").SetPropertyValue("Address2", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtAddress2")).Text);
p.GetProfileGroup("Address").SetPropertyValue("City", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtCity")).Text);
p.GetProfileGroup("Address").SetPropertyValue("State", Globals.IntParse(((DropDownList)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("ddlState")).SelectedValue));
p.GetProfileGroup("Address").SetPropertyValue("PostalCode", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtPostalCode")).Text);
p.GetProfileGroup("Address").SetPropertyValue("Country", Globals.IntParse(((DropDownList)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("ddlCountry")).SelectedValue));

p.SetPropertyValue("PhoneNumber", ((TextBox)cuwWiz.CreateUserStep.ContentTemplateContainer.FindControl("txtPhone")).Text);

p.Save();

Using ProfileBase lets you get around the use of the auto generated class, or the hand created class you might make. It does make it a little harder to set and get the properties though. If you did have the WebProfile or ProfileCommon class, you could just say

wp.FirstName = "Steve";

I wrestled with this profile stuff here for a good hour or two before I finally found on the net that Web Applications don’t auto create the class, etc. The class that it does generate though is derived from ProfileBase, so you can just use that and be OK. It would be nice if Web Application Projects did create the class though, it would have saved me a couple of head scratching hours. :)