.NET Developer Days 2014 Conference

September 17, 2014 on 10:13 am | In Continuous Integration, DotNet, Software Engineering | No Comments

2014-09-17_11-53-07I will be speaking at .NET Developer Days 2014 in Wrocław, Poland. The conference will be held between 14th and 16th October 2014 at the City Stadium in Wrocław. The topic is “Continuous integration and deployment in .NET with Jenkins CI and Octopus Deploy”. Here is the conference website: http://developerdays.pl/.

Software decay

September 3, 2014 on 7:47 pm | In Software Engineering | No Comments

At my company CODEFUSION we are working with bigger and bigger customers. We are getting hit by terms that were little known to us until now. Last time we did get a contract to sign with a term (literal translation from Polish) software “illness”. The word illness was in quotation marks. The term was new for me, so I started to dig. It turned out that what was meant here was probably “software decay” (called also software rot, code rot, bit rot, software erosion or software entropy). It was something we all software developers are fighting with. Sometimes without knowing it has a name. Software does not change, bits don’t rot, programs are not getting ill. But the environment in which they are executed often changes. New hardware is being installed, dependent software changes (for example database engine is being updated). So the software slowly deteriorates. Faults are being discovered that were never seen before, performance drops, the overall stability decreases. We see it everywhere: websites are “old” after a year or two, windows applications written for windows without tiles look “funny” in Windows 8. From experience I know environments where some ancient technologies are still used to develop the software because every one it afraid to touch a running system. So: software rots.

It was quite funny how quickly I discovered a decayed piece of software that was written partly by myself. I work with Visual Studio. For various reasons I’m deep into addins development for Visual Studio. To my surprise one of my addins stopped working suddenly. I haven’t done anything with it since a year or so. What I did I’ve done is I installed a new version of Visual Studio and unknown number of updates for both the old and the new one. Maybe it was what rotted my addin. So I quickly spin up the debugger and found that this line of code

   1:  _toolWindow = _applicationObject.Windows.CreateToolWindow(
   2:     _addInInstance,
   3:     _progId,
   4:     _caption,
   5:     _guid,
   6:     ref docObj);

rises an exception. ProgId seems to be wrong. No matter it was all right a year ago. Now it is wrong. Google seemed to know nothing about it. So I fiddled around. _toolWindow is a custom window for my addin. It’s “Windows” type. Visual Studio API is not the cleanest part of the code I’ve seen. Not surprisingly there was a “Window2” type. With a method “CrateToolWindow2” that produces an object of “Window” (of course not “Window2”). But it was exactly what I need. So I’ve changed the implementation slight to:

   1:  Windows2 windows2 = (Windows2)_applicationObject.Windows;
   2:  _toolWindow = windows2.CreateToolWindow2(
   3:     _addInInstance,
   4:     Assembly.GetCallingAssembly().Location,
   5:     _class,
   6:     _caption,
   7:     _guid,
   8:     ref docObj);
   9:                      

And voila! It magically worked. I have no idea why the class name is better than ProgID. Maybe it is an SDK update, maybe something else. But what ta heck! I will let it work until it rots again.

WCF services behind NAT problem and solution

August 28, 2014 on 12:02 pm | In ASP.NET MVC, DotNet | No Comments

Problem: We have a set of WCF services working on a server. We have an ordinary ASP.NET page that calls one of the services to display its state. When we call that page we is supposed to look like this:

image

Green page indicates everything works fine.

At a customers we’ve installed the services.

image

The message was: There was no endpoint listening at http://…/Services/BasicDataService.svc/DeliverServiceState that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

We quickly discovered that there was nothing wrong with the services. Our app worked fine and we were able to call the “.svc” endpoint in the browser.

But why do we get this exception?

A quick call to the service on the server reviled no response (“This page can’t be displayed”). Ping to the domain reviled “Request timed out.”. Oh, we are getting nearer. Our status page calls the services from the inside of the customers network (both website and services are in the same site on IIS). It looks like we are in NAT. The requests coming to the company router from outside are correctly routed to the server working inside the the company network. The domain name is translated with help of DNS to the global IP address and the company router routes the communication to the server which works with his local IP address. But if we are connecting from inside we are hitting wrong side of the router and it is not able to translate the global IP to the local IP correctly. We are not landing where we supposed to.

Reconfiguration on the company router should do the trick (NAT-Loopback). We informed the company admin to do the change and proceed  with a quick workaround. We changed the hosts file to fix it right away.

Hosts is a text file located in C:\Windows\System32\drivers\etc used by the system to locally route the addresses to IPs. We can add the server local IP address and match it with the domain name.

That solved the problem. But soon we got another one.

We added a second binding to the site and our information page wen red once again. This one was actually easy to solve. We called the ”.svc” service directly and got:

This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting ‘system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled’ to true or specifying ‘system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters’.
Parameter name: item

Yep, multiple bindings present but WCF configured to work with only one. We had to change the:

<system.serviceModel>
   <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />

to

<system.serviceModel>
   <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

in the services web.config.

We added the second address to the hosts file and voila!

Pictures from DWX’14 conference

July 23, 2014 on 8:33 am | In DotNet, Netduino, Software Engineering, Tinkerforge | No Comments

This year I was once again an invited speaker at the Developer Week conference in Nuremberg, Germany. I was speaking (in German of course) about the basics of hardware programming in .NET. Developer Week is biggest developer conference in Germany: 250 session, 150 speakers. It consists of .NET Developer Conference (DDC), Web Developer Conference (WDC) and Mobile Developer Conference (MDC). Here are some pictures from the conference.

Waiting for the first .NET wrist watch

May 9, 2014 on 2:26 pm | In Continuous Integration, DotNet, Netduino | No Comments

Almost a year ago there was a Kickstarter campaign to found a first .NET Micro Framework watch: Agent smartwatch. Nice thing about it is that you will be able to program it using C# and Visual Studio. While we are still waiting for the product there is a SDK with an emulator. It is from the same guys that gave us Netduino! I decided to check it out.

Think about it: you have a Continuous Integration server running your builds and you want to monitor it on the fly. Is there a better device to do it than a wrist watch? So I thought and decided to check it out.

Here is a quick project I’ve hacked to proof the concept. But before we begin let me show you the result:

image

Neat! Isn’t it?

I’m using Jenkins as my Continuous Integration server. It has a set of APIs for the developer to use. I decided to give Json API a try.

I typed:

http://jenkins_url/api/json?tree=jobs[name,lastBuild[building,result]]

What gave me nice Json result:

{

  • "jobs": [
    • {
      • "name": "Demo4Dev1",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      },

    • {
      • "name": "Demo4Dev2",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      },

    • {
      • "name": "DemoTest1",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      }

    ]

}

I went to the Agent website and got the SDK. I fired up Visual Studio and wen New Project –> Visual C# –> Micro Framework –> AGENT Watch Application

image

Which gave me a Hello World application.

I added System.Http and System.IO references and headed straight to get the HTTP response and read the response stream to the end. Like this:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(JenkinsApiUrl);
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string respStr = sr.ReadToEnd();

Now I needed something to parse the Json text. Luckily for me I wasn’t the only one. There is nice NuGet project with Json parser. To get it issue:

PM> Install-Package Json.NetMF

Having it I head straight to deserialization:

Hashtable deserializedObject = Json.NETMF.JsonSerializer.DeserializeString(respStr) as Hashtable;

Now I went to hack and slash over over the result to find out everything is all right.

// Assume success
bool generalFailure = false;

foreach (DictionaryEntry de in deserializedObject)
{
    foreach (Hashtable ht in de.Value as ArrayList)
    {
        foreach (DictionaryEntry job in ht)
        {
            if (!job.Key.ToString().Equals("name"))
            {

                Hashtable ht2 = job.Value as Hashtable;
                if (ht2 == null) continue;
                foreach (DictionaryEntry results in ht2)
                {
                    if (!results.Key.ToString().Equals("building"))
                    {
                        if (results.Value.ToString().Equals("FAILURE"))
                            generalFailure = true;
                    }

                }
            }
        }
    }

}

I have added two result images to the resources:

image

And headed to show the result:

// initialize display buffer
_display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

// Show result
_display.Clear();
Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);

_display.DrawText("Jenkins", fontNinaB, Color.White, 35, 10);
if (generalFailure)
{
    _display.DrawText("FAIL!", fontNinaB, Color.White, 35, _display.Height - 20);
    Bitmap image =
        new Bitmap(Resources.GetBytes(Resources.BinaryResources.storm), Bitmap.BitmapImageType.Bmp);
    _display.DrawImage(_display.Width / 2 - image.Width / 2,
        _display.Height / 2 - image.Height / 2,
        image, 0, 0, image.Width, image.Height);

}
else
{
    _display.DrawText("SUCCESS!", fontNinaB, Color.White, 35, _display.Height - 20);
    Bitmap image =
        new Bitmap(Resources.GetBytes(Resources.BinaryResources.sun), Bitmap.BitmapImageType.Bmp);
    _display.DrawImage(_display.Width / 2 - image.Width / 2,
        _display.Height / 2 - image.Height / 2,
        image, 0, 0, image.Width, image.Height);
}
_display.Flush();
I packed everything in a never ending while loop with small delay:
while (true)
{
  // ... code ...
  Thread.Sleep(10000);
}

Done!

That’s the screen with the failure notice.

image

I can’t wait to get the Agent Watch to make the final app!

Hardware programming in .NET at DWX 2014

April 18, 2014 on 2:12 pm | In DotNet, Netduino, Tinkerforge | No Comments

Once again I was invited to give a talk at the DWX – Developer Week in Nuremberg, Germany.  Last year I was speaking about “Continuous Integration in .NET”. This year it is a time to give “Hardware programming in .NET” a try. I will show how to create software for Netduino, Tinkerforge and Raspberry Pi using .NET Micro Framework, .NET Framework and Mono. Oh, and I’m planning to build the circuits the talk! It should be a lot of fun. And here a small example of RGB LED attached to Raspberry Pi and programmed in Mono.

 

CODEFUSION’s Illuminated RaspberryPi

 

To get mono to your Raspberry Pi issue following commands:

sudo apt-get update

sudo apt-get isntall mono-runtime

sudo apt-get install mono-mcs

And here is the source code for the blinking LED:

using RaspberryPiDotNet;

namespace HelloRaspberryPi
{
    class Program
    {
        static void Main(string[] args)
        {
            GPIOMem ledRed = new GPIOMem(GPIOPins.Pin_P1_22);
            GPIOMem ledGreen = new GPIOMem(GPIOPins.Pin_P1_18);
            GPIOMem ledBlue = new GPIOMem(GPIOPins.Pin_P1_16);

            while (true)
            {
                ledRed.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledRed.Write(false);
                ledGreen.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledGreen.Write(false);
                ledBlue.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledBlue.Write(false);
            }
        }
    }
}

Prototype is showed showed on the following picture.

2014-04-17 17.01.59

The image below shows the used Raspberry Pi pins used. For Description and matching PIN names to numbers see here http://elinux.org/RPi_Low-level_peripherals. I have used the GPIOPins.Pin_P1_22 = GPIO25 for red, GPIOPins.Pin_P1_18 = GPIO24 for green and GPIOPins.Pin_P1_16 = GPIO23 for blue. Plus the P1-20 for the grounding. I was using 3 220 Ohm resistors connected the the colors (+).

image

To get it running you will have to reference and use the RaspberryPiDotNet.dll from https://github.com/cypherkey/RaspberryPi.Net/ and have the BCM2835 library compiled. You can get install it using following commands:

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.3.tar.gz

tar -zxvf bcm2835-1.3.tar.gz

cd bcm2835-1.3.tar.gz

./configure

make

sudo make install

cd src

cc -shared bcm2835.o -o libbcm2835.so

And compile your program using Mono.

sudo msc ./Program.cs –r: ./RaspberryPiDotNet.dll

and to run it

sudo mono ./Program.exe

Voila!

If you happen to attend the Developer Week / .NET Developer in conference between 14th and 17th July 2014 please drop by to see my talk!

PS. My mono is enclosed in a self printed case (using our 3D printer) with my company CODEFUSION logo.

4Developers conference in Warsaw

March 18, 2014 on 8:41 pm | In Uncategorized | No Comments

jestem_prelegentem_4dev

I will be speaking at the 2014 4Developers conference in Warsaw, Poland. In a matter of fact I have not one session but two! Tja, it’s actually THE one. But divided into two parts. Nevertheless a great deal of .NET continuous integration goodness comes into your direction. Watch out! For details see the conference website (Polish only). 4Developers conference .NET Track. April 4th 2014 at the Gromada Hotel Airport in Warsaw. Don’t miss it!

I am a Software Engineering Subject Matter Expert at CompTIA

March 11, 2014 on 12:41 pm | In Software Engineering | 1 Comment

sme_comptia

I’m very proud to be a Subject Matter Expert at CompTIA in Chcicago, USA. I was invited to participate in a Software Engineering and Networking for Programmers workshops in their headquarters at Downers Grove (west Chicago suburbs). The first day of Software Engineering workshop went by and was quite intensive. I’m working in a small international (Canada and USA) group of professionals from institutions like IBM or Illinois State University. We are creating and asserting items for a new set of certifications that CompTIA is developing. We are basically writing the questions for the exams the candidates will have to pass to get the certification. It’s quite intensive but it is a lot of fun with interesting people. I’m very glad that I was chosen to be Subject Matter Expert (SME) by CompTIA.

.NET hardware programming basics

December 18, 2013 on 12:01 pm | In Article, DotNet, Netduino, Software Engineering, Tinkerforge | No Comments

I’m a “bits sculptor”! I work with bits to create beautiful software. I have done it myself for years and now I’m running a software development company to create “better software”. But I was always jealous of people creating more tangible items than software. Not that I ever thought about software as a lesser creation then physical objects. Oh, no! Creating good software takes the same amount of effort and talent as creating for example a good car. But still. But you cannot “touch” the software you are creating. So I decided to go a bit into hardware. And what is the better way for .NET software developer than to go programming .NET based electronics?!?! 

Yesterday I’ve added a talk about the basics of .NET hardware programming to my repertoire. It’s basically the material I’ve worked on while writing the two articles published by dotnetpro Magazin in Munich, Germany. The first one was about Netduino and it was published in 08/2012 issue and the second one was about Tinkerforge from the 12/2013 issue. I’ve added a bit information and a demo for Raspberry Pi and Mono. I gave a talk at the meeting of .NET Developers Group München (17.12.2013). It went quite well. Despite the technical versatility I had to manage (and believe me the table was crowded with electronics!).

And here are two photos from the talks I gave last week (11.12.2013) at the Opole University of Technology. The topic was: testing mobile software and I showed (among other things) our RoboTouch project.

wyklady_otwarte_2013-12-11-7702wyklady_otwarte_2013-12-11-7710

Eventful week

November 22, 2013 on 11:01 am | In Article, Continuous Integration, DotNet, Software Engineering | No Comments

Last week was quite eventful. I’ve talked about Continuous Integration in .NET and about how do we use it at my company CODEFUSION at the IT Academic Day 2013 at the Opole University of Technology (OUTech). CF-IT Academic DayIt was an event organized by the .NET Group from the OUTech and Microsoft Poland. The auditorium nearly full! Of course I’ve showed my funny CI gadget "Great Integrator Helmet". It connects wirelessly to the CI server and transfers a feedback about failing build by blinking and hauling. As usual it was very well noticed by the auditorium Winking smile

And since we are at the topic of tinkering with electronics: Idnplogo_dr’ve described how to build such a thing using Tinkerforge and .NET and together with Bernhard Kord written an article about it. It went “live” this week in the 11th 2013 issue of dotnetpro Magazin in Munich, Germany. If you are keen in German language (the article is written in German) take a look at http://www.dotnetpro.de/articles/onlinearticle4689.aspx for more details!

« Previous PageNext Page »

Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.