Posts Tagged “.NET”

I was lucky enough to be asked to present at NDC Sydney - probably the best conference I have ever been to. ... [Read More]
Continuously deploying from GitHub to Azure should be easy. In this video I discuss 2 issues I found when deploying an API using ASP.Net 5 ... [Read More]
While everyone is making the move to MVC 6 (and it is pretty awesome), not everything is there yet. ... [Read More]
I seriously love my Windows Phone… except for the availability of apps. ... [Read More]
One of the most common issues I am finding with teams moving from Team Foundation Version Control to TFS-Git is that they are including files in their repositories that they shouldn’t. The most common offenders are .suo user settings files, Nuget packages and Azure publish settings.   Luckily, the solution is straightforward.   1. Ensure you have no pending changes. 2. Close the solution 3. Go into Team Explorer and click Settings      4. In the Settings tab select Git Settings      5. Open the .gitignore file from GitHub that is specific to Visual Studio projects and copy the contents to the clip board. https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore Figure: the .gitignore includes a list of all of the files that you want to avoid committing to your repository    4. In Settings | Repository Settings, click the Edit link next to ‘/,gitIgnore’        6. Paste the contents of the .gitIngore from GitHub into the .gitignore file and Save it.      7, In Team Explorer, navigate to the Changes window. Enter a comment and click Commit.      8. Click the Sync link to take you to Unsynched Commits      9. Click the Sync button to push your updated .gitIgnore      10. If you have included files in your repository that you wish to exclude from the repository but not delete from your local working directory refer to Remove files from your repository (so that they aren't tracked), but leave them in the working directory on my page for... ... [Read More]
This is what I consider to be my list of ‘essential’ tools / skills for a serious .Net developer. An Agile or Lean methodology Learn Scrum If your projects are not being delivered successfully Scrum will either enable you to start delivering software, or highlight the reasons why you aren’t. The Scrum Guide which contains all the rules of Scrum is 13 pages long. There is no excuse for not having read it. If you aren’t doing Scrum, or you aren’t doing it well… get some help. ALM Learn TFS Out of the box, it gives you so much. I find it incredible how many people have TFS but are only using it for Source Control. Source Control Learn both Team Foundation Source Control and Git, and the strengths of each. Work Item Tracking Being able to successfully deliver value to the customer while triaging bugs requires efficient work item tracking processes and tools. Continuous Integration Why-oh-why isn’t everyone doing CI? Check in your code, have a magic fairy build it, test it and tell you if you’ve broken anything - sounds too good to be true AND it only takes 60 seconds to setup! ‘Fail Fast’ is probably my favourite development catch-phrase: If you find out that the code you’ve just checked-in conflicts with some-one else’s code 2 minutes after you’ve checked it in, it’s easy to resolve the issue. If you only find out there is an issue a week later, it’s much harder. Deployment: Get your CI... ... [Read More]
ASP.NET.Identity 2.0 is out, and it adds a bunch of great features. - Two-Factor Authentication (SMS, Email or custom)- Account Lockout- Account Confirmation via Email- Password Reset- Sign out everywhere- Choose your Primary Key type (string, int, Guid)- IQuerable Users and Roles - Delete User- Enforcing Unique User Names   The upgrade was more fiddly than I thought it would be. Here is what I had to do. I hope it helps.   1. Update Entity Framework to 6.1 2: Update all your OWIN components if they already exist in your project. (Yes. NuGet should handle this for me. It didn’t. Upgrading the Owin components before the Identity packages resolved some issues for me)   3: Update Microsoft ASP.Net Identity Core and then ASP.Net Identity EntityFramework   4: Your model has now been updated to v2.0 ! If you are running Code First Migrations you now need to create a migration to reflect the changes to the database. Figure: When you try to create the migration, it will tell you that the model backing the db context has changed. To resolve it, you need to update the constructor of your dbcontext.   Figure: Adding ‘, throwIfV1Schema:false’ as a parameter to the constructor will allow you to run the application, and create the required Code First Migration.   Figure: After updating the db context constructor, Add-Migration works as expected.   Figure: You can now inspect the changes to the schema in the Migration. Upgraded ! Now check out the links below... ... [Read More]
We ALWAYS automate our deployments. We always deploy often. This has many, many benefits. The most important of which is early feedback. An essential tool when managing deployment of many sites to different environments is a smoke-test page that validates the configuration of the website in that particular environment. SSW.HealthCheck makes it easy to check your site status.   Figure: SSW.HealthCheck let’s us see at a Glance that on this site: the database connection is valid, but Debug mode has not been turned off and SMTP is not configured. We can also easily extend SSW.HealthCheck to perform other tasks like ensuring your database is up to date. I’ll address this in a future article.   Create a new web project Lets start with a new web project, then we’ll add SSW.HealthCheck. Figure: Create a new web project called Northwind.MusicStore.WebUI   Figure: Select the MVC template and click OK.Optionally: add the ‘Web.API’ and ‘Add unit tests’ options. Add SSW.HealthCheck.MVC5 to WebUI Figure: Select Tools | Library Package Manager | Package Manager Console. Enter Install-Package SSW.HealthCheck.MVC5 and press Enter. Note: Alternatively you can use Tools | Library Package Manager | Manage NuGet Packages for the Solution, and then search for SSW.HealthCheck.MVC5 and click Install. Figure: Ensure SignalR is configured: Open Startup.cs from the root of your application. Ensure app.MapSignalR() is being called in the Configuration method. Figure: Run the application and navigate to /HealthCheck Configure HealthCheck to Test Your Connection Strings Figure: Because we are using Entity Framework Code First, and it... ... [Read More]
I am running Windows 8 and Visual Studio on my Mac using Parallels. The project I am currently working on is configured to use IIS Express, but I want to test it using a VM that contains IE8. As it turns out this was quite simple to setup. 1. Download the VM from http://www.microsoft.com/en-au/download/details.aspx?id=11575  or http://www.modern.ie/en-gb/virtualization-tools 2. Open the VM using Parallels (File, New, Add Existing Virtual Machine). 3. Change the Windows 8 VM and the VM containing IE8 to both obtain their own IP addresses from the local WiFi router.             Virtual Machine | Configure | Hardware | Network. Change type to WiFi 4. Change the configuration of the web application to use the Windows 8 VMs IP Address              e.g. change it from http://localhost:63527/  to http://10.0.0.20:63527/ 5. Edit the binding in your IIS host config file (You can find it in  %userprofile%\Documents\IISExpress\config\applicationhost.config ) Find the entry for your application and change it from from to 6. Disable windows firewall on the Windows 8 machine. 7. Run Visual Studio as Administrator and run the application. It will now be accessible from the IE8 Virtual Machine. References: http://stackoverflow.com/questions/5442551/iisexpress-returns-a-503-error-from-remote-machines ... [Read More]
It’s important to consider how strictly you should encapsulate your data access logic within the repository layer Repository Layers allow us to abstract our data access away from our application. There are two common approaches.   Approach #1: Fully Encapsulated – The Strict Repository In this model you pass in simple types or DTOs as parameters to repository methods and receive enumerated lists of results in return. (ie. IEnumerable / ICollection / IList)   Benefit: Your data access is 100% completely abstracted away from your core application. This model only requires the Entity Framework to be added to your Data project. Cons: It’s more work. Every data access query requires a new repository method and a change to the interface.   Approach #2: The Flexible Repository In this model you encapsulate complex queries, or queries that will be re-used inside your repository, but simple queries can be performed by the calling client because the Get() method accepts a filter operator and returns an IQueryable that provides great flexibility.   Benefit: It’s less work. A developer can build user interface that performs simple CRUD operations on the entity without needing to add methods to the Repository.   Cons: This is a ‘leaky’ abstraction where your implementation is likely to leak into your other layers. The Entity Framework is required as a reference in any project where you are performing queries that require EF specific extensions (e.g. .Include(c=>c.Children) )   For each application you need to weight the cons and benefits of... ... [Read More]
FireBootCamp has been an amazing experience. ... [Read More]
When working with the Entity Framework Code First I will often get the error below: An exception of type “System.Data.SqlClient.SqlException’ occurred in EntityFramework.dll but was not handled by in user code’ Additional information: Cannot drop database [database name] because it is currently in use. To force a delete of the database, follow the steps below. Figure: This exception is common after you have opened a LocalDb database in Visual Studio.   ... [Read More]
Sprint 1 was great, but now the guys are really getting going. ... [Read More]
I got asked for a 60 second intro to using TFS-Git. 1. Go to your personal TFS (e.g. adamstephensen.visualstudio.com)   2. Create a new Team Project Figure: Click on New under Recent projects  & teams Figure: Enter the name of the Team Project (E.g. FireBootCamp)Select Git as the version control system.Select Create project   3. Clone your Repository locally Figure: In Visual Studio, open Team Explorer and click Select Team Projects Figure: Select the team foundation server to connect to, select the team project and then click Connect Figure: Right click on the Repository and select Clone Figure: Enter the path to the local repository and click the Clone button   4. Add your MVC project to the Repo Figure: Create the MVC Project Figure: Right click on the Solution file and click Commit Figure: Enter a comment and click Commit and Sync ... [Read More]
Configure Your Build 1. Open the Build Pane Figure: From Team Explorer choose Builds   2. Create a new build definition Figure: Click on the New Build Definition link   3. Enter build definition name “AdamS.MembershipSample.CI”(CI for Continuous Integration) 4. On the Trigger tab choose ‘Continuous Integration’   5. On the Source Settings tab remove any unwanted Source Control folders Figure: Remove any items that do not apply to your project (sometimes items from other solutions will appear in this list – remove them)   6. On the Process tab, ensure that the solution is being built   7. Save the Build Configure Build Notifications 1. Run the Visual Studio Build Notification application. From C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\BuildNotificationApp.exe   2. Select the build Figure: Select the Build that you just created and click OK Start a Build Figure: Go to Team Explorer | Builds. Right click on the Build and choose Queue New Build   Figure: When the build is complete, you will get a green or red icon indicating the status. ... [Read More]
Week 1 at FireBootCamp has been amazing. ... [Read More]
In this video I chat to Michael Crump about his experiences developing for Windows Phone 8. ... [Read More]
I caught up with Dino Esposito, Technical Evangelist at JetBrains, to discuss the lessons learnt building mobile apps and sites. ... [Read More]
If you are working with Azure, you need to check out the Azure PowerShell Cmdlets. powerful + simple = AWESOME ! Here are a few very simple samples that I use to manage my Azure VMs. (There are Cmdlets to cover all of the Azure features and I’ll cover managing Cloud Services in a separate post.) Figure: “Get-AzureVM“. It lets you easily see what VMs you currently have provisioned (i.e. Are being charged for).   Figure: The Stop command let’s you de-provision a VM so you aren’t charged for it while you aren’t using it. I schedule this to run on each of my dev VMs.        No more $200 Azure bills for me because I forgot to shut down my large instance !   Figure: Of course you can start your VMs as well.   In case you weren’t sold… here is a list of a few of my other favourites. Add-AzureWebRole Restart-AzureVM Add-AzureWorkerRole Restart-AzureWebsite Get-AzureRole (List your roles) Set-AzureDeployment Get-AzureService (List cloud services) Set-AzureRole (Sets the # of instances) Get-AzureStorageBlob Set-AzureService Get-AzureVM (Get VM info) Show-AzurePortal Get-AzureWebsite Show-AzureWebsite Get-AzureWebsiteDeployment Start-AzureVM Get-AzureWebsiteLocation Start-AzureWebsite Move-AzureDeployment (staging->prod!) Stop-AzureVM New-AzureVM Stop-AzureWebsite New-AzureWebsite     For more info: Check out MSDN http://msdn.microsoft.com/en-us/library/jj156055.aspx ... [Read More]
If you are a ReSharper user (and you should be), check out the new dependency graph. It is awesome for easily getting a high level view of the dependencies between projects and layers in your solution. Figure: ReSharper 8 introduces a dependency graph to its architecture tools.     Figure: I structure my solution to reflect the Onion Architecture. http://rules.ssw.com.au/SoftwareDevelopment/RulesToBetterMVC/Pages/The-layers-of-the-onion-architecture.aspx I have layers for UI, Business Logic Interfaces, Repository Interfaces and the Domain Model. I then inject my dependencies into these layers.I like to structure the dependencies under a different solution folder so as to emphasise that the dependencies exist outside of the application core.     Figure: R# now generates a dependency graph of your solution (or a selected part of your solution) and by default groups the projects by Solution folders. I love this because with a few clicks I can get a very clear idea of the dependencies between the different layers in my solution, and see where references exist to dependency projects. I unselected three items to remove noise from the diagram: the Solution Items folder (which contains the deployment project and documentation), the Common folder (which contains cross-cutting concerns) and the Dependency Resolver project which configures the IOC container.     Figure: I generated the ReSharper dependency diagram as preparation for the first Sprint Review meeting and immediately noticed a dependency from my Client (UI) layer to a ‘Dependency’ project. No No No No No !!!     Figure: We refactored to inject the dependency... ... [Read More]