Posts

Showing posts with the label Tips and Tricks

JustMock and "Failed to initialize coreCLR" on RC2

Image
Unable to start the process. Failed to initialize CoreCLR, HRESULT: 0x80131500 I just installed ASP.NET Core RC2 and was able to get it working from the command line, on some new basic tests projects. But when I tried to do it from Visual Studio I got the following error.  If I tried to run "dotnet" in a console opened from Visual Studio, I would get the same error. So the issue was that something was off for the VS configuration/environment.  After verifying that "dotnet" was able to run perfectly everywhere else I took into the task of comparing the environment variables (dichotomically, of course). One particular variable made the difference: "JUSTMOCK_INSTANCE=XXXXX", so that lead me to notice that JustMock was interfering with it somehow.  So, if you use JustMock just turn it off for RC2 projects. (No need to uninstall it, just disable the profiler)

Red blinking issue on Microsoft Display Dock

Image
Red blinking light? Check the power supply cord. I just got my Microsoft Display Dock courtesy of MS after pre-ordering a Lumia 950XL. But after the first attempt I just got a red blinking light on the front and nothing more. The phone won't recognize it and the display connected would just go to sleep. After playing with it a bit I realized the USB-C connector on the dock's power supply (identical to the "fast charger")  was a bit loose. I then compared to the one that came with the 950XL and voilà!  See the difference below. Left: Adapter from the 950xl box | Right: Adapter from the Display Dock Since it is shorter (manufacturer error? bad batch? who knows...)  the adapter packaged with the Display Dock won't reach the connector properly. However, it will fit in and charge the 950XL perfectly. I think one of the reasons is the thick casing in the Microsoft Display Dock. Check it out. The case is sturdy and thick. So if you happen to have a Micros...

Get-ChildItem vs Dir in PowerShell

Image
Batch as usual Recently I was in the need of modifying a huge amount of files across a network share. After installing Serviio media streaming service I noticed that it will crash "randomly". After checking the logs it was clear that ffmpeg was crashing when trying to open subtitle files that were not in the encoding indicated by the Serviio console. I needed a quick way to update all subtitle files to a common encoding, so I decided to convert all files to UTF8. Since I use a windows environment I went directly to PowerShell and wrote this.  Get-ChildItem -path .\ -filter *.srt -file  | ForEach-Object { (get-content $_.FullName) | Out-File $_.FullName -encoding utf8 } This worked almost right except for files with "[" or "]" (among other symbols) on the name or path. To solve it, just added the "-LiteralPath" switch to tell powershell not to consider any wildcards on the path name and just use it exactly as it is.  Get-ChildIt...

The lambdas, the anonymous and the events

Combining lambdas, anonymous methods and events feels natural in C#, and we use them almost as a reflex, they help us to create closures and avoid creating state variables outside the scope of our methods or passing extra state data through event calls. But one thing that come with events is the fact that writing good applications implies making good use of the resources, meaning we have to dispose those we no longer need. When using events with lambdas and anonymous methods, is possible to forget about that, thus writing code that is not efficient and prone to crashes. Will start this 2-part series talking about the subscribe/unsubscribe behavior. Subscribe/Unsubscribe lambdas and anonymous methods Let's begin with a basic scenario using events in a single-thread context for now; just to keep it simple. The code fragment below contains the HelloEventArgs implementation as well as the publisher class MyClassWithEvents . public class HelloEventArgs:EventArgs { ...

When somebody changes my code...

Well, initially I might get upset, but only if they break something. But here I am not talking a team member changing your code... No... that's OK This blog entry is about that 'non-deterministic' behavior that sometimes happens to 'us' while developing software and all of the sudden something does not work as it 'should' be. Who does not hate that kind of bugs right? This example is a real case scenario using Telerik components in a web application. Consider the following piece of ASPX code, I have placed a button and a label, the button 's click event in code-behind event will change the value of the label. Pretty simple right? Just a button with a javascript confirmation dialog before performing the page's post back. Now lets 'ajaxify' this... Using the new ajaxified code now have pretty much same effect, except we are not performing a full page post back, but only updating elements inside the UpdatePanel control. But what if I...

Git, git extensions and the case-sensitive thing...

As a general rule, I always use some kind of source control on all my projects. For the matter of fact I use GIT even when some people might find that weird, being myself a .NET developer .... But hey... GIT is in my opinion the best things out there when it comes to really good team development tools. Then the second part is to use it with people online, for that github.com is pretty good, and the final part is a good add-in for Visual Studio or a shell extension. I use Git-Extensions for all that and so far, except for the little problem I am going to explain here, I have no complains at all. The problem: Git branches are case-sensitive, so you can have "test" and "TEST" as different branches, and it will work fine if you use linux as a client. But when using git-extensions from Windows, and ran into a huge problem, where one of my friends was pushing code and I was not able to see it. She was uploading code to same branch but just with different casing. Is ...

Referencing Silverlight assemblies from non-SL projects

Image
One of the best things about Silverlight is that represents a set of portable functionality that you can expect to run almost anywhere. Its similarity – although reduced – with WPF results in an amazing way to develop rich UIs and logic in Browser-side apps. And then results normal to want to reuse Silverlight code from our own .NET applications. Reusing code from Silverlight assemblies is possible; the referencing process works well because Silverlight is a subset of .NET Framework, so that “by logic” should just work. Of course this is not all happiness, there are lot of limitations, but it will work as long as you keep yourself into the borders of certain assemblies like Mscorlib , System ,System.Core ,System.ComponentModel.Composition and Microsoft.VisualBasic , playing with others might give you mixed results. Now the trick. You SHOULD NOT add the reference to the Silverlight PROJECT. You MUST add the reference to the Silverlight ASSEMBLY. So let’s assume you have a scenario with...

WCF, Data Contracts and Enums

Image
With Windows Communication Foundation it is easy to create any kind of services, of course my opinion could be biased because I am a .net (mainly c#) developer, but I really find hard to believe that someone could disagree with such statement. Of course there is a lot of know-how and trouble for beginners, specially trying to understand that WCF integrates all communication models we know (web, tcp, pipes, message queues) under one uniform paradigm. But there are some moments where you hit a rock in the path; years ago I stumbled upon the following scenario: I had a library “common.dll” that I used from both the client and the service. You might think this is not something you would do too often, and many people would say “that a client must not know anything about the service internals”. Well… that’s true, but this is not that case. It is just a situation where a client shares some business logic with the service. And the problem? Well, there is no problem with that config...