Tag Archives: Visual Studio

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: \computernamec$ – then it prompts you to login. Use your AD username and password, so

domainusername 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:WindowsSystem32runas.exe /netonly /user:domainusername “C:Program FilesMicrosoft OfficeOffice12excel.exe”

C:WindowsSystem32runas.exe /netonly /user:domainusername “C:Program FilesMicrosoft Visual Studio 8Common7IDEdevenv.exe”

C:WindowsSystem32runas.exe /netonly /user:domainusername “C:Program FilesMicrosoft SQL Server90ToolsBinnVSShellCommon7IDESqlWb.exe”

 

Replace “domainusername” with your info. So if your domain is mycompany then it would be mycompanysteve.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.

Visual Studio 2008 and SQL 2005 Careful…

Since Visual Studio 2008 came out yesterday, I installed it. One gotcha – if you already have SQL 2005 installed, check custom on the install steps, because VS2008 will install SQL Express 2005 and start up an instance of that, I had to then uninstall SQL 2005 Express. PITA :)

C# .NET Test Driven Development with Visual Studio 2005

As of late I have been stuck in C++ world. MFC/Win32, pointers and HRESULT’s. Ugh. Earlier this week I got a chance to get back to C# and .NET (aka My Roots).

I needed to create a class library for a project, basically from scratch, since there was no existing library created. I started to go at it, and about 2 minutes into it, I was like, wait, let me try to do this test first. Test Driven Development (TDD) is one of the pillars of the Agile development methodology. In the past, there has always been existing code, that was written Non-TDD, so basically what you would end up doing is adding tests to this existing code. When doing that, you kind of get into a rut where you find it easier (at least you think it is easier), to add new code, then write tests after.

So, I fired up Visual Studio 2005, created a solution, added a test project, with a test class, and one method, and started writing a test, basically on how I would think I would exercise my non existing class library. By doing this, it really makes it easier in my opinion to practice TDD.

Run the test, doesn’t even compile, why? because I haven’t even created my class library project yet. No compile = Tests Fail. What I need to do is make my tests pass. So I add just enough (but not to much) to make it pass.

I keep adding to my class library so I can get my tests to pass, and after a while, I have a nice tight class library for my project, fully tested, great code coverage, and more confidence in my code.

What is really nice, is that when I actually needed to use the class from a webpage, I basically copied my unit test code into the web page and it works, just as expected.

I’d have to say that with Visual Studio 2005, and .NET languages, doing TDD is really kind of fun. People will always say, “well you spend more time writing tests than code”, and well, yes, that might be true the first time you are writing your class library, if a bug does happen to come up, you basically have everything in place to track it down, whereas if you do not have tests, then you spend your time debugging and tracking down things for hours. A little time up front saves you tons of time down the road, and you become way more confident in your code base.

If you haven’t tried TDD with VS2005, go for it!! I bet you will really enjoy it!

VS2005: Missing Project Template – Where did my Console App Template Go?

So I fired up VS2005, and wanted to make a quick prototype C# Console Application, except I couldn’t find the Project Template!!

Found out that if you close Visual Studio,  run the VS CMD prompt, and run this: “devenv /installvstemplates”

It should add the templates back.

Good to go!

Visual Studio 2005 – C++ Unit Testing – Not so good

So, as of late, I have been programming more in C++ than in C#/.NET. The first order of business was getting everything to Visual Studio 2005, which has been accomplished. In .NET, there is built in Unit Testing, Code Coverage, Refactoring, etc. In Visual Studio C++ unmanaged/native C++, you don’t get any of that. (Thanks Microsoft!) Now, if you code in managed C++, you get all the nice features (I’m pretty sure you get all of them).

What you can do, and there are some articles/blogs on the net, is set up a Unit Testing project in managed C++ and then link in your managed C++ projects. This works. Sometimes. It looks better on paper than when you actually try to implement it, depending on your environment and how you have things laid out.

We are making static MFC (probably the first problem – MFC :)) libs for a Core library, and we had to tweak a bunch of settings (ie: make a new build configuration), just so we could link into the managed C++ projects. There were numerous issue, just too many to list here. Things just don’t work nice together.

When we managed to get things to actually compile, and run, then the code coverage would show all the Microsoft API’s as not covered, since the libs were statically linked in to the test project.

Overall, my experience with Visual Studio 2005 and unit testing has been a good one. As long as you are using VB.NET or C# :) 

It is so nice since it is integrated into the IDE, and it can make unit tests for you from existing code. This all would be a god send for C++, yet, there isn’t anything there.

And as long as I am griping about it, intellisense in C++ really isn’t that good. I did some research and found Visual AssistX, and we purchased it. Really is worth the money. Adds refactoring and intellisense on crack compared to the built in intellisense.

Anyways, I will follow up with a few more posts with my experiences on C++ unit testing. I tried a few other frameworks, and actually got CppUnit to work well, so I will blog on the steps I took to make it work.

Just because you develop in C++ doesn’t mean you can’t develop with an Agile mindset, it is just a little bit harder to get started. Unit Testing, Refactoring, Code Coverage, and then Continuous Integration. Hopefully over time I will get some more posts up about these things and how as a C++ developer using Visual Studio 2005 you can accomplish them (or at least the way I did it) :)

By no means am I saying I know the best way, but it seems that there isn’t much out there talking about this stuff for a native/unmanaged C++ dev using Microsoft technologies, or maybe I just can’t find it.