Tag Archives: Visual Studio

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



How To Speed Up Visual Studio Start Up

Add /nosplash to the end of your visual studio shortcuts..

image

also you can also go to tools->options and change the startup to an empty environment to speed up open times

 

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. :)



What Have I Been Up To? Windows 2008, Drive Backups, VS2008 Web Programming, SSIS Stuff

I have been pretty busy lately. I have some posts that I want to write up, but it seems they are getting bigger and bigger, longer. More stuff :)

Just a highlight, this weekend I decided to do a full drive backup and create a restore cd, I followed this process. http://www.darkchip.com/DriveImageXML/Complete%20System%20Recovery%20Process.html

I just didn’t stumble upon that. I did some research on drive backups, etc and found Drive Image XML. From there I did a backup to USB. But then I needed a way to restore, so I followed the BartPE tutorial for Drive Image XML and got that all set up. Just gives you a sense of confidence, knowing you have a full backup. Why did I decide to do this? Because I wanted to try Windows 2008 Server on my laptop, as a workstation, so next I did that.

Installed Windows 2008, set it all up. I am liking it, but there are some caveats so far. Wifi is off by default, you need to install some extra stuff. Turn on audio services, etc.

IE is totally locked down, but I installed Firefox right away anyways. Windows Live Writer won’t install, but yea you can get it to work – you need to get the MSI – http://on10.net/blogs/sarahintampa/20879/Default.aspx

The OS doesn’t find the iPhone, so I will have to figure that out. I haven’t installed the "Desktop Experience" yet, I want to try not installing it for as long as I can. Win2k8 flys with everything turned off by default.

Also have been working on some side projects, web site and other blogs/projects. Getting deep into VS2008 and .NET 3.5, which is fun. Ran into some debacles with the ProfileBase auto generation stuff, probably another post.

Also, so cool stuff in SSIS that I probably could write up, we will see.

I am all over the board right now, I know, but it is fun, doing Programming, Database, Web 2.0 blog stuff, System Admin, the whole gamut. I love it.



How To: Connect to SQL Server, VS TFS, etc using Windows Authentication when computer is not on Active Directory Domain (XP and Vista!)

Whew, long title, amazing results!

Problem: You have a laptop or computer and you are working remotely for a company. You VPN in. Your computer is not on their Active Directory (AD) domain. You try to connect to SQL Server using SSMS or Analysis Services using Excel, but it doesn’t work because it is using your user, not a domain user. How do you get around this?

Answer: Well, this is what I have found (tested on XP only) – start->run: \\computername\c$ – then it prompts you to login. Use your AD username and password, so

domain\username and password, and check the box to save password.

Seems that XP will save that in your authentication list somewhere, and then you can use SSMS or Excel to connect to the SQL Server via Windows Authentication!

This trick also works for TFS Build Servers/Team Explorer (tested with VS2005 Team Explorer) ..

Now for the fun part – Vista. The tricks above don’t work on Vista, but you can still get it to work. Here is what you do…create some shortcuts…

C:\Windows\System32\runas.exe /netonly /user:domain\username “C:\Program Files\Microsoft Office\Office12\excel.exe”

C:\Windows\System32\runas.exe /netonly /user:domain\username “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe”

C:\Windows\System32\runas.exe /netonly /user:domain\username “C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe”

 

Replace “domain\username” with your info. So if your domain is mycompany then it would be mycompany\steve.novoselac for example.

What happens is that then when you run those apps from those shortcuts it will prompt you for your domain password, you put it in, and it runs the app in the context of your domain user. You can then change the icon for each of these pretty easy, just browse to the exe in the second part when clicking the change icon button on the shortcut properties (the shortcuts are actually links to runas.exe which is a generic icon)

In Vista, for instance, if you are testing SQL (SSMS), you might get this error:

Login failed for user ''. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)

The shortcuts above will get you around it in the situation where your computer is not not on the domain or you are not logged in as a domain user..

These tricks above are especially good if you need to connect to SSAS (Analysis Services) since it is only Windows Authentication. And also, the IT department doesn’t really need to have consultant machines on the domain, or VM’s set up, etc, instead they can use these workarounds



PHP, IIS7, Vista, VS2005

Tonight, just for the heck of it, I decided to get PHP running on my machine. I am running Vista (not SP1 beta). I already have IIS installed, so that pre-req was taken care of.

First thing, I made sure I had everything turned on..

Start->Run->Programs and Features->Turn Windows Features on or off…

image

I made sure CGI and ISAPI was checked. I then downloaded and installed PHP (http://www.php.net/get/php-5.2.5-win32-installer.msi/from/a/mirror)

When I went through the install, I changed the path from Program Files to Windows (read online that it would be better – rights – if in Program Files it doesn’t have the same rights as in Windows)

Then, I opened IIS7, and  went to “Handler Mappings” and clicked “Add Script Map”

image

It will prompt you when you hit ok to add to CGI stuff, hit Yes.

Then you can make a test PHP page in your wwwroot, put <?php  phpInfo();  ?> in there and it should work!

Now, as an added bonus, I wanted to use VS2005 IDE to develop PHP scripts, and found VS.PHP (http://www.jcxsoftware.com/vs.php) which lets you make PHP projects in VS2005. There is a 30 day trial, but then it is 99 dollars. I installed it and tried it , pretty awesome.

I don’t know how much PHP programming I will do, but every now and then it is nice to dabble into other technologies and code up something, or just keep up on the latest trends.