Archive for the “Visual Studio” Category

When you want to build an Azure application, but you don’t have SQL Express installed the build action in Visual Studio will fail.

You will receive the following message in your output window:

Windows Azure Tools: Failed to initialize the Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.

To fix this you open the Windows Azure SDK Command Prompt:

Windows Azure SDK Command Prompt

And enter the following text:

dsinit /sqlinstance:.

dsinit /sqlinstance:.

This will cause Azure to use the default instance (with no name). You can switch this to whatever you like, just replace the . (dot) by the appropriate MS SQL instance.

The result will look like this:

Development Storage Initialization

Good luck, happy coding.

Comments No Comments »

image

Check the ‘Insert attribute value quotes when typing under Text Editor > HTML > Format :)

Comments No Comments »

When creating one to many relationships one might bump into the following problem:

Consider the following database design:

Tables:

Customers
-Id
-FirstName
-LastName
-…snip…
-City

Cities
-Id
-Name
-Zip

With a many to one relation from Customers.City to Cities.Id

While this is easy to do in SQL, the LINQ to Entities syntax might seem a bit different.

Consider the following piece of code:

City c = (from city in ctx.CitySet
where city.Name == cityName && city.Zip == cityZip
select city).FirstOrDefault();

This selects the city (if it exists) or null.

Now the problem is: IF the city exists, how do I point the current customer’s city to that particular city.

I tried this:

//customer is a customer object
customer.City = c;

But that resulted in duplicate cities in the database.

The solution was actually quite easy, I browsed through all the properties (Intellisense!) and found this:

customer.CityReference.EntityKey = c.EntityKey;

This resulted in the one to many relationship I had in mind. No duplicate cities in my database.

I love database normalization!

Comments No Comments »

First of all: for those who think that there is an easy solution. I’m sorry, there is not.

The problem is located in the .edmx file, and not in the designer.cs file as I suspected first.

When you add an .edmx and take a look at it with notepad you’ll see this:



	
	
		
		
			
				
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

Now you add a table:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
						
							
								
								
								
							
						
					
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
				
			
		
	

As you can see I’ve added a table ‘Users’ with ‘UserID’, ‘Name’ and ‘Birthday’.

You can also see the difference between the 2.

Now when you delete the table again from the design surface this is what ‘junk’ that stays behind:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

As you can see lines 9 and 12-17 weren’t there in the original -empty- model. You’ll need to clean those up manually.

diff

Removing those lines will give you the possibility to re-add your previously deleted table.

Comments No Comments »

Does not work.

Outlook.Application and Outlook._Application are both interfaces. And I want to use them as a class in my program (I don’t know how they made that work).

I wanted to extend Outlook.Application and add a simple method to create a new email. But that does not work since you have to implement a bunch of methods which I hardly understand.

Thank Microsoft for creating extension methods, so here is my solution:

using System;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace SendToExtended
{
	static class OutlookExtensions
	{
		/// 
		/// Creates and returns an Microsoft Outlook MailItem
		/// 
		///
an instantiated Outlook application
		/// A new MailItem object
		public static Outlook.MailItem CreateMailItem(this Outlook.Application outlook)
		{
			if (outlook == null)
				throw new ArgumentException("outlook parameter cannot be null");

			return (Outlook.MailItem)outlook.CreateItem(Outlook.OlItemType.olMailItem);
		}
	}
}

Comments No Comments »

A while ago I wrote this (Dutch) article on how to perform LINQ to SQL for your SQL Compact databases, since Visual Studio did not understand this, we had to do it manually, as described in the article just mentioned.

But since the release of .NET Framework 3.5 SP1, and the therein included ADO.NET Entity Framework, it is now possible to generate a model out of a SQL Compact database!

Unfortunately this is not (yet) possible for Smart Device applications (Windows Mobile), but who knows what the future might bring!

Comments 1 Comment »

(I quote):

Developer Express and Microsoft are proud to announce a new version of CodeRush licensed exclusively for C# developers working in Visual Studio. The new product is called CodeRush Xpress, and it includes a fresh selection of hand-picked features taken from CodeRush and Refactor! Pro.

And I love it! It has very handy functions for refactoring your code very fast!

I recommend it for everyone!

Usefull links (both contain the downloads):

If you are interested in learning the features you can access these movies:

Dustin Campbell also presented a video on this tool, among other useful Visual Studio 2008 shortcuts  on PDC 2008, you can find it here (click below for wmv-hd download).

Comments 2 Comments »

I just downloaded the Visual Studio 2010 CTP (you can get it here) (an easier way to download the CTP is described here).

When you have downloaded everything you will end op with an VHD (Virtual HardDisk) and VMC (Virtual Machine Configuration). The first one contains the actual C drive of the VM, and the VMC some (default) configuration.

These files are useless in VMware, because you can’t load the VMC, nor can you use the VHD.

But you can convert the VHD (the hard disk) to a VMware-readable format.

These are the steps:

  1. Download WinImage trial here (choose your flavor).
  2. Install/extract (depending on your flavor).
  3. Open the VHD with WinImage: winimage
  4. Open your VHD (you might need to change the filter).
  5. Select Dynamically expanding disk: winimage-dyn
  6. Choose where to save your file.
  7. Now create a new VM in VMware, a Server 2008. And when it asks to create a new Hard Drive you select: Use an Existing Virtual Disk, and point it to your newly created vmdk.

Good luck!

Problems? Leave a comment :)

Comments 1 Comment »

I would like to clarify a previous post of mine.

As stated there I will be attending Microsoft Tech·Ed EMEA 2008 – Developer in Barcelona the 10th until the 14th of November this year.

There is so much to tell about this, it will be a week PACKED with programming, no silly lessons like school, but information on a decent level.

I already made my agenda for the week (it can change though), in order for them to know how many places they must reserve for each seminar.

I mainly chose WPF and Silverlight, and User Interface. Because that is what I like, the interaction between the program and the user.

Databinding and LINQ is also very interesting, and I will be attending a seminar about that subject.

More information will follow.

Comments No Comments »

Should you ever want to install SQL Server Management Studio Express 2005 you MUST run it as Administrator.

When you try to install it on Vista (by double clicking the .exe) it extracts the files to a temp folder.

Then it launches the setup, asking you some questions. After that UAC asks you to gain Administrative access.

No problem so far, but at the end the installer notifies you of error number 29506, it cannot modify the security properties.

Solution is described here, run the installer as Administrator from cmd.

Comments No Comments »

And shepherds we shall be, for thee my Lord for thee, power hath descended forth from thy hand, that our feet may swiftly carry out thy command. We shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine Patris, et Filii, et Spiritus Sancti.