25. Februar 2014

Visual Studio 2010 Projects Always Out of Date Solved by Changing the File Date

If your Developer Studio suddenly tells you, that your project is "out of date". If it keeps telling you, even though you rebuild all. If a simple F5 always pops the annoying "These projects are out of date" dialog box, then ...

... you probably ran into a bug that lets Visual Studio think, that a totally unrelated file on your disk is a dependency of your project(s). This file probably has been added to your disk recently and for unknown reasons Visual Studio regards it as dependency.

In my case its "C:\PROGRAMDATA\NVIDIA CORPORATION\DRS\NVDRSDB0.BIN" from a newly installed Nvidia driver. Other files have also been reported like "C:\PROGRAMDATA\SOPHOS\SOPHOS ANTI-VIRUS\CONFIG\CONFIG.BOPS".

There might be other reasons for this behavior, like missing header files. These can be resolved easily, by adding the missing file or removing it from the solution.

This article is about solving the case of "Visual Studio Project Out Of Date Because of Weird Dependency".

The standard way to solve this is to
1. find out which file claims to be newer than your project.
2. Exclude the offending file.

Step 1:
Enable Visual Studio debugging and check the log. Basically:
in
%ProgramFiles(x86)%\Microsoft Visual Studio\10.0\Common7\IDE\
after
</configSections>
insert

<system.diagnostics>
  <switches>
    <add name="CPS" value="4" />
  </switches>
</system.diagnostics>
Then use DgbView to get the log output.

Step 2:
There seem to be ways to exclude the file or folder from the list of dependencies. This can be done for each project or system wide (which is probably what you want).

I am not a fan of changing details in large XML config files with weak documentation and multiple possible insertion points of which only one works and the others make things worse, and which affects all projects.

But I still tried.

Unfortunately, I do not get these solutions to work. My project still wants to rebuild every time.

There is another solution: 

Just change the "modified" file date of the offending file.

I am using Attribute Changer to date the file back by 2 years (or whatever). Simple and works.

For the record: I download tools like Attribute Changer only from trusted software repositories. You should too. Do not download from the "homepage" of the program. Anyone can make a homepage and send you anything.

_happy_attributing()

17. November 2013

SpendenCache von LENDENSHURZ

Gerade habe ich den neuen SpendenCache von LENDENSHURZ bekommen.

Wir erinnern uns: Jeden Tag einen Euro spenden.

Endlich fliegen die Euros nicht mehr lose in der Hosentasche herum. Schluss mit klimpern.

Ab jetzt leise, hygienisch, stylisch, immer verfügbar.

_happy_caching()

UPDATE: Ich komme momentan nicht hinterher. Sammle täglich einen Euro. Bin schon auf 2 € Stücke umgestiegen. Trotzdem wird der Stapel immer höher. Meine Laufstrecken im Alltag treffen so selten auf Bedarf. Sollte wohl mehr in der Innenstadt rumlaufen. Will nicht auf Bulk-Spenden für Eisbären/Taifun/Sahel/Amnesty ausweichen. Das ist extra, wäre zu einfach. Die Regel lautet: "Statistisch 1€ pro Tag an Bedürftige", die dich persönlich fragen, egal was du sonst machst.

22. Oktober 2013

Which Star Trek Character Are You?

Mein Ergebnis vom "Which Star Trek character are you?" Quiz...

You are Data:

Data
71%
Jean-Luc Picard
70%
Spock
70%
An Expendable Character (Redshirt)
65%
Geordi LaForge
65%
Leonard McCoy (Bones)
50%
Deanna Troi
50%
Mr. Scott
45%
Chekov
40%
Will Riker
40%
James T. Kirk (Captain)
40%
Beverly Crusher
35%
Worf
30%
Uhura
10%
Mr. Sulu
5%
Even though you are a genius 
you are always striving to be 
better.


Und wenn wir schon dabei sind "Which Star Wars character are you?"

You are Qui-Gon Jinn:
Overall, you're a pretty well balanced 
person. But maybe you focus a little 
too much on the here and now. 
Think about the future before its too late.

Qui-Gon Jinn
64%
Han Solo
62%
Obi-Wan Kenobi
59%
R2-D2
59%
Princess Leia
58%
Lando Calrissian
55%
C-3PO
55%
Chewbacca
55%
Padme
55%
Yoda
53%

_happy_quizzing()

30. September 2013

Statistisch Spenden

Ich werde jetzt jeden Tag einen Euro spenden. Das tut nicht weh. Das muss drin sein.

Man wird ja immer wieder mal gefragt, ob "ma mal nen Euro hat". Mal vom Obdachlosen, mal vom Punk, mal vom Musikanten, mal in der Fußgängerzone, in der Unterführung, im Park, auf der Straße, mal mit Gegenwert (Obdachlosenzeitschrift, Kugelschreiber, Glückskeks, Musik) und mal ohne.

Der Befragte schaut sich dann gerne den Fragenden genau an, um zu entscheiden, ob der Fragende auch ein Bedürftiger ist. Man will ja wohl überlegt entscheiden, damit die Spende nicht aus Versehen an den Falschen geht. Man will ja nicht dem Falschen was geben und damit irregeführt worden sein. Irregeführt zu werden mag man überhaupt nicht. Lieber nichts geben. Im Zweifel gegen die Spende. Das ist Quatsch.

Die meisten, die fragen, sind bedürftig. Das ist dem geneigten Leser so klar, wie mir. Aber die Konsequenz ist für mich neu. Ich gebe ab jetzt jedem der fragt, solange das Budget reicht. Statistisch gesehen erreicht es die richtigen.

Nicht mehr überlegen, ob die Musik vom Musikanten gut war. Klar, Schifferklavier nervt, aber wollen wir deshalb auf Musikanten verzichten. Einfach geben. Statistisch die Straßenmusik unterstützen. Nicht mehr überlegen, ob der Penner den Euro gleich in Fusel anlegt. Einfach geben. Statistisch gesehen kauft er ja auch was zu beißen. Nicht überlegen, ob das Bein vom Invaliden nur untergeschlagen ist. Einfach geben. Statistisch sind da auch echte arme Schweine dabei. (Mal davon abgesehen, dass einer, der ein Bein unterschlägt, um zu betteln, sicher auch kein leichtes Leben hat.)

Einfach geben. Statistisch gesehen ist das richtig.

Dabei ist ein kleines logistisches Problem zu lösen. Den Euro hat man nicht immer parat. Typische Situation: "Haste mal nen Euro", Der Geldbeutel ist in der Tasche, beide Hände voll mit dem Einkauf, "sorry, würde ja gerne, vielleicht nächstes mal".

Lösung: immer 2 Euro im First Level Cache (Hosentasche). Damit die Pipeline voll bleibt, maintaine ich zuhause zusätzlich einen Second Level Cache in Form einer Schale mit Eurostücken an der Wohnzimmertür. Da kann man auch mal wechseln, falls der Geldbeutel nicht die richtige Stückelung hergibt. Die Schale dient auch als Leaky Bucket Filter, um den Durchsatz zu regeln. Performanceprobleme fallen schnell auf, wenn die High Water Mark erreicht wird. Dann muss man den Output aufdrehen.

_happy_giving()

4. August 2013

Mocking Controller Context with HTTP Request for Unit Testing ApiController of ASP.NET WebApi

For a new project I am using ASP.NET Web API. Web API is a great way to implement REST services.

Web API makes many things easier, but there is one thing missing: simple unit testing of controllers. You can definitely call controller methods like Get() and Get(id). But it is not easy to prepare the controller's server context so, that Request.CreateResponse() works correctly. Also, if you want to return the URI of a newly created (Post-ed) item, then a lot of wiring has to be done around ApiController's properties Request and ControllerContext,

Here is my solution: I am extending ApiController with a MockRequest function, which sets up the routing stuff like routes, route data, request URI. The goal is, that the controller method can:
- check the request URI including the query,
- create URLs using the route template,
- create a HttpResponseMessage as result.

The MockRequest method is called like:
var controller = new ProductsController(productRepository);
controller.MockRequest(HttpMethod.Get, new { controller = "products", id = 1 });
Product result = controller.Get(1);
Assert.Equal(result.Name, "Tomato Soup");
Implementation:
public static class ApiControllerExtensions
{
  public static void MockRequest(this ApiController self, HttpMethod httpMethod, object routeValues)
  {
    var routeValueDict = new HttpRouteValueDictionary();
    foreach (var prop in routeValues.GetType().GetProperties()) {
      routeValueDict.Add(prop.Name, prop.GetValue(routeValues, null));
    }
    var config = new HttpConfiguration();
    var request = new HttpRequestMessage { Method = httpMethod, RequestUri = new Uri("http://localhost/") };
    var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
    var routeData = new HttpRouteData(route, routeValueDict);
    self.ControllerContext = new HttpControllerContext(config, routeData, request);
    self.Request = request;
    self.Request.Properties.Add(HttpPropertyKeys.HttpRouteDataKey, routeData);
    self.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
    self.Request.RequestUri = new Uri(self.Url.Link("DefaultApi", routeValues));
  }
}

Note: the argument routeValues also takes additional properties, which are automatically converted to query parameters, because they do not fit the route template. Just as it should be.

Note: the route template is fixed to "api/{controller}/{id}". If you have a different template, change it or make it a parameter of MockRequest. I did not want too many variables, because my project only has /api/controller[/id] URIs.

Note: don't ask me why the request is set up with a default URI "http://localhost/", then later the RequestURI property is set explicitly. Without the prior "http://localhost/", self.Url.Link() always returns null.

Note: there is more to do if you want to unit test model validation as well. See Unit test WebAPI Controllers with Model Validation. Looks good, but does not compile with my NET 4.0. If you also want to check the formatting, then you might need to talk to an in memory HTTP server (which will also include the model validation).

_happy_routing()

6. Juni 2013

Immediate Disconnect for strophe.js

Updated A Website Chat made easy with XMPP and BOSH with my findings on immediate disconnect with strophe.js on page unload.

Problem:
The connection should be closed when the page unloads. Unfortunately strophe.js (at least up to version 1.0.2) disconnects asynchronously, which does not work when the page is destroyed. After some time the XMPP server will notice, that the page disappeared and will close the connection. But if you do not want to wait, then we have to force strophe to close immediately.

Solution:
There is a strophe patch, which allows for synchronous connection closing. The patch must be applied to the strophe.js file. Just 2 lines of code in strophe,js and one line before calling disconnect().

See A Website Chat made easy with XMPP and BOSH.

_happy_closing()

3. Juni 2013

Erster Weblin mit schwarzer Krone

Es passiert ja nicht wirklich viel im Weblin-Land, aber manchmal gibt es doch einen Grund zu feiern. Wir haben den ersten Weblin mit mehr als 2^16 Punkten (=65536) und deshalb mit schwarzer Krone am Avatar.

Hier ein Screenshot von http://www.weblin.com/toplins.php:


Macr@Soft ist ewiger Ruhm sicher.



_happy_pointscollecting()

http://de.blog.weblin.com/2013/06/erster-weblin-mit-schwarzer-krone.html
http://blog.weblin.com/2013/06/first-weblin-with-black-crown.html