C# and .NET

  • Yet another custom binary protocol library implementation

    Recently I have been involved in a project that required a custom binary protocol specification be written for interaction between some custom hardware and a central processing server. Before you wonder why re-invent the wheel I did look into protoBuf but although perfect for what I was doing, implementing this on the custom hardware would have been more difficult. The communication was going to occur over TCP using sockets. Some of the requirements of this protocol included: 1. A small size protocol to minize network traffic 2. Libraries that could be used across multiple applications to handle the protocol 3. An extendable protocol so that new packet types could be…

  • Calling .NET MVC 3 action method via jQuery ajax and handling serverside redirect

    Recently I developed a .NET MVC 3 application where jQuery would be a core part of the design and it was accepted that we did not have to worry any special optimization for phone or mobile devices or disabling of javascript. During development of this application I wanted to make use of page redirects while using the inherited .NET Controller RedirectToAction() method. This worked well. When making HttpPost or HttpGet requests I would do the standard re-direct as necessary and everything worked as I would expect. However, as mentioned the majority of our requests were via jQuery ajax. And not only that, the responses to the ajax request would vary…

  • ViewModel composition and using Partial views with Partials

    Slightly confused by the title of this topic? I can see why. Even I didn’t know what to give the name to the problem a recent problem I encountered and I ended up resolving it. Instead I’ll try and state the problem in my definition below: Please note. There might be better ways of doing this, or perhaps I’m doing it all wrong. Take this with a grain of salt and if it works for you, that’s great. Otherwise that’s great too… History Whilst being new to MVC .NET I did alot of reading on best practices, any practices and different methods of using the concept to achieve my desired…

  • Calling Delphi 6 DLL from c#.NET and blasted rounding issues

    Recently I had the need to call a Delphi DLL from a .NET application. The delphi DLL would be performing a number of floating point arithmetic operations and returning results in as a string. In order to debug the delphi DLL another delphi application was written that uses this same interface and outputs the results. The problem I started experiencing was that the results produced when calling from my c# application varied from those called from the delphi application. Both used the same DLL and both produced the same inputs. I don’t have much in-depth knowledge about floating point numbers but I have read enough to know that most of…