Friday, 28 September 2012

System.IO.FileNotFoundException: Could not load file or assembly 'Missing.Assembly.dll, Version=1.0.20.15800, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified

Have you ever seen a error like the one below: System.IO.FileNotFoundException: Could not load file or assembly 'Missing.Assembly.dll, Version=1.0.20.15800, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified The first thing to think is Ahhhhhhh! I have all the references what is going on??! Don't panic here's a few steps to diagnosing this issue, and hopefully resolving it. STEP 1. Make sure you can debug the code and ascertain which assembly is throwing the exception. STEP 2. Once you know which assembly is complaining about the missing DLL you then need to find the corresponding project and check that project's references:
If the reference that is in the exception exists then move on to STEP 3. STEP 3. If the reference exists then you need to look a little deeper, into the second part of the exception or one of its dependencies. This is key, what this means is that Missing.Assembly.dll is referencing an assembly you're not (FACT). What you need to do is ascertain exactly which assembly it is referencing and which version it is referencing. This is actually quite tricky for large projects but the easiest way to find out is by looking at where the exception occured (i.e. the line of code) and what that particular piece of code needs to work in terms of references. Do this by looking at the using statements:
Good luck :) Any questions?

Monday, 27 August 2012

Upgrading to Windows 8

Bonjour Amigos, Just upgraded to Windows 8 Pro on the following machine: (Just look at the spec)
It was a very seamless and easy installing, however my version of Kaspersky had to be un-installed as it was not compatible with Windows 8, apart from that everything else worked fine. At first it was difficult to use as navigating around the desktop (app) without a start icon is confusing...
Whenever you press the start key you are redirected to the new Windows start screen! It can be quite confusing at first but intuitive minds can get used to it quickly. For example, if you wanted to search for an application or file, you carry out the same action you would on Windows 7 START + "app name", however it looks completely different:
This concludes my analysis for upgrading to Windows 8, just to summarise I would recommend upgrading!

Monday, 2 July 2012

Using ADO.NET to connect to a custom DB provider

Using ADO.NET is a great way to connect to data provider that exists outside the .NET framework to connect to a database. There are many data providers out there, MySQL,PostgreSQL, FlySpeed etc. which are in commercial use but are not neccesaraly that popular. It can be difficult sometimes create a DAL for a custom database architecture. Fortunately we have ADO.NET along with DbProviderFactory class which allows any custom DB provider to connect to the .NET CLR and allow developers to write custom execution queries against the database. When using these custom DB providers you need to update your application configuration file so that the .NET runtime has knowledge of the DbProviderFactory that you intend on using, if you check your machine.config (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config) for .NET v4.0 you'll should see the following entries:

<section name="system.data" type="System.Data.Common.DbProviderFactoriesConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />



<DbProviderFactories>       
     <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
         
    <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />   
    
    <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />     
</DbProviderFactories> 

These are the default factories that cone with the .NET framework, however if you want to introduce your own custom factory you can just add an entry. Depending on whether you want your factory to be available across applications or not you could add the entry to your local application/web configuration file.

Wednesday, 9 May 2012

JSONP aka JSON with PADDING

JSONP is a hack pattern which allows JavaScript from one domain to execute with JavaScript from another domain. This is technically not allowed as it violates cross-domain polcy, howeber throught the JSO work-aroud it can be acieved. "Why?" I hear you ask, well the answer is simple, someone exposes a service on one machine and you want to consume that service on another. "But that's already possible!" you cry, well yes however you can't execute that service inline, look at the following example: On my.domain.com you have a local script called myscript.js, so the full URL to that script is my.domain.com/myscript.js. Inside this script you want to make a call to other.domain2.com/their.js and execute their JavaScript, it doesn't work, unless you explicitly ue the <script> tags. But that's pointless because you want to execute their inline with yours; that's where JSONP comes in. Using JSONP you are able to overcome this hurdle by setting up an 'understanding' between the service and the requesting JavaScript. This can be achieved by placing a query string parameter in the URL that the service understands, e.g. other.domain.com/their.js?jsonp=yes. The service will 'wrap' it's response in a JavaScript function, which the requesting JavaScript will execute once it's received the request. Once it executes this request, it will hopefully get some meaningful JSON that it can interpret and use for it's own devices.

Tuesday, 10 April 2012

ASP.NET Web API (Beta)

I have been recently looking into the new ASP.NET Web API to find out what features it offers and it's quite interesting. It seems to following a convention over code model similar to that of ASP.NET MVC, so for those familiar with those constructs it should be an easy API to follow. You use the global.asax.cs file to name your routes (just like ASP.NET MVC), however you use the MapHttpRoute overload instead e.g. routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/notifications" ); This is a typical route where the {controller} template representes the controller name that is found beneath the controllers folder.

Wednesday, 11 January 2012

Using Modinizer

Modinizer is a great new javascript library for detecting browser features without having to write too much unnecessary code for abstracting cross-browser compatibilities. For example rounded corners is a feature that was desired for many UX (user experience) developers and before CSS3 could only be accomplished with javascript hackery. Now with modinizer it is possible to detect using the library whether the feature is enabled and code corresponding classes appropriately. When modinizer is included on a page it dynamically updates the HTML class attribute with a set of classes that identify what that browser understands, e.g. multiplebgs = multiple backgrounds, or no-multiplebgs meaning doesn't support multiple backgrounds. Allowing you the developer to code accordingly for both scenarios and thus future proof your web application. The same also applies to new HTML5 elements such as video, and localstorage. A quick Modiziner.localStorage test will reveal whether or not the browser supports that.

Tuesday, 10 January 2012

Reading Files Across Servers

There are many ways to access data across servers that are shared on the same network. Depending on your setup will determine what is the best approach. It is possible to use the COM model to access the UNC as and authenticated user of that machine, i.e. machine name = CPU123, user = CPU123\user.whoever. The problem with this is approach is that if your servers are on different domains then is will be a huge headache to maintain all of those users, configuration file sounds like the best approach, but that will still yield a huge file. One app setting for each user. The approach I adopted was to use MSMQ and created a WCF service for sending messages to that queue and reading the state of the particular file using a FileWatcher. Worked well!

Saturday, 15 October 2011

Using NCover with Cruise Control.NET and Nant

I had the task of integrating NCover into our continuous builds and integration. At the time I was using Cruise Control.NET v 1.5, NCover v 3.4.18 (classic), and Nant v0.91. I came across several problems when doing this, however I finally came across a solution where by using Nant I was able to build my application, run my Nunit tests and the run my coverage. The route I took involved using the NCover Nant task DLL that comes with NCover and running it over my tests. The issue which held me up the longest was the fact that in order to run coverage over your test DLLs you need to ensure that you include the pdb symbols in your build output, otherwise you'll be going nuts!

Sunday, 9 October 2011

IOC - Inversion of Control

Currently, I'm using Inversion of Control (IOC) for most of my application building which I'm finding really useful and quite powerful. Some people consider IOC to be a pattern which follows the three R's: Register, Resolve and Release which is how you would use it by default. IOC usually takes some kind of container which holds all the mappings between objects, for example, if you wanted to use the class Chicken everytime you referenced the interface IAnimal then in you container you may have the following registration: _container.Register.To(); The syntax depends on which IOC library you are using; there are several. My current preferred choice of IOC library is Castle Windsor, which makes using IOC inside applications quite fun and simple.

Sunday, 10 July 2011

ASP.NET MVC

Hi all, I'm back after a long time off. What I would like to discuss is ASP.NET MVC in comparison to ASP.NET.

Let’s give a quick introduction ASP.NET (Active Server Pages) is a server side coding language used for rendering HTML (Hyper-Text Markup Language). This is achieved by using the notoriously infamous server tags <% code goes here %>.

The ASP.NET runtime was built as an abstraction to allow developers to code in their native .Net languages, e.g. C# to create powerful web applications. The problem (amongst other things) was that the level of abstraction meant that coding “simple straight-forward” applications was quite easy and efficient, however coding custom or complex applications became quite difficult, e.g. two form tags on the same page.
The main problem was that through this level of abstraction some granular control was taken away from the developer in order to have a windows forms style development experience. Even controlling Ids on a particular HTML element became quite a laborious and painful task.

With ASP.NET version 4.0 some vast improvements had been introduced to make most coding scenarios easier, however with the revolution of test driven development, the improvements (in my opinion) still weren’t enough – introducing ASP.NET MVC.
MVC (Model View Controller) for those who do no t know is a design pattern used throughout all kinds of programming languages. It essentially boils down to one primary concept “separation of concerts”, meaning everyone has a job and they should only be concerned with fulfilling the requirements of their job. Fox example, in a typical restaurant theirs a chef, a waiter, and a manager. It’s not chef’s responsibility to take your jackets and make sure your comfortable in your seat, just like it’s not the waiter’s responsibility to ensure that the restaurant’s targets are met and that everyone shows up to work on time.

The MVC design pattern has been so successful in coding web applications that Microsoft and the ASP.NET team decided to introduce their own implementation. What this means is that we now have a design pattern directly “embedded” into the .NET framework, and used correctly can lead to power web applications as with ASP.NET but also powerful unit testing. ASP.NET MVC gives some of the control back to the developer and allows you to deepen your understanding of ASP.NET runtime.

With ASP.NET MVC 3.0 there is a new syntax introduced for creating ASPX pages called Razor. It is what I would describe as very clean and concise. The reason being that a lot of the repetitive tags and directives are no longer needed and writing C# inline with HTML (or even JavaScript) looks a lot nicer to read! Which for some developers such as myself is very important. What this means that less keystrokes are now required to produce the same content with ASP.NET thus allowing the developer to get on with other important tasks, such as, poking people of Facebook.