Search This Blog

Thursday, December 21, 2017

Microsoft web architectures of the day: Web Forms vs MVC vs Web API

I was tasked today with finding out what is the best pick to convert our desktop application into a fully web based one.

Came across the 2 following links, which I found very good, where I think most of the essential topics are covered.




Wednesday, December 6, 2017

Having problems setting 2 panels in a windows form, where one is top-docked and the other fill-docked, but the fill-docked one is overflowing into the top one ?

Play with the panels "send to back" / "bring to front" (mouse right click).

Sunday, October 1, 2017

Need to open several links in Chrome at once? Try this trick

Not programming related, but figured out today something interesting:

In chrome, bookmark folders containing N links - if you click the folder with the mouse wheel button, all links inside the folder will be opened!

Good to know, if you happen to require to open a given set of links, together, once in a while.


Monday, June 12, 2017

Sunday, May 28, 2017

How can I see WCF server logs?

What is suggested here worked for me.
This is cleaner. Update: this has always been working for me, and seems more complete/easier. Put it  right before the closing configuration outer node.

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
      <listeners>
        <add name="ServiceModelTraceListener" />
      </listeners>
    </source>
    <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
      <listeners>
        <add name="ServiceModelTraceListener" />
      </listeners>
    </source>
    <source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
      <listeners>
        <add name="ServiceModelTraceListener" />
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add initializeData="Service.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" />
  </sharedListeners>
</system.diagnostics>

Thursday, May 18, 2017

mySQL Error Code: 3037 Invalid GIS data provided to function st_geometryfromtext.

If you have been trying to find what's wrong with your geometry objects and why your sql insert statement is failing, check this, which reveals the cause (congrats to all of us who went "as far as completing a BSc degree in computer science" (and how far is that?) and could yet miss this...).

I was startled because, in cloning some tables from one DB schema to another, I was facing this error. But how come values that do exist in one table cannot be inserted (are treated as invalid) in another ?

Later on I heard that this was a change made in later versions of mySQL. So I assume the records were inserted at the time this constraint was not there yet. And they must have kept existing data as valid for backward compatibility.

Tuesday, May 16, 2017

ILMerge errors (exited with code 1, could find dll, assembly has a value for its PeKind flag that is incompatible...)

After leaving very few spots in my head unscratched (I am environment-conscious, there are those who act with a bit less self restrain and throw their computers through the office's window), I came up with the following solution to ILMerge errors of all sorts. ILRepack is being developed to replace our endeared ILMerge, and although I am sure all of you keep deep feelings (feel free to make them public) about it, my solution was to:

  1. backup C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe renaming it to, say, _ILMerge.exe 
  2. place a copy of ILRepack.exe 
  3. rename it to ILMerge.exe  (it follows the exact same ilmerge command line parameters syntax)
 And that's it. Rebuild your solution.
Yes, you are rid of ILMerge. Unbelievable.

Monday, May 8, 2017

Can't force MSBuild to use a different SDK Tools path

My scenario is: my build server, which uses Jenkins as the CI tool, runs on Windows 2008, which does not support the newer Windows 10 SDK. So I tried playing with both SDKToolsPath and FrameworkOverride msbuild command line parameters, but without success (although not the two together). I ended up trying a hack I thought of while the question from this thread (the link points to this very solution I posted there) - overwriting the lc.exe from SDK 7 with the newer LC.EXE from SDK 10. My build finally succeeded. Did not spot any side effects so far...

Thursday, May 4, 2017

Building VS projects via command line

An important thing to keep in mind when running msbuild providing properties (in the form of /p:[Key]=[Value]) (for instance, a list of properties useful in building clickonce applications can be found here) is (taken from MSDN):
Global properties are properties that are set by using the /property switch on the command line, or properties that are set by the integrated development environment (IDE) before a project is built. These global properties are applied to all projects that are built by using this Engine.
In other words, if you build a solution with 7 projects (1 start-up plus and 6, say, class libraries), and you provide the AssemblyName parameter like /p:AssemblyName=MyAssembly, you will end up with 7 assemblies with the same name, one with an EXE extension (depending on your project template) and the others with DLL. I, for instance, wanted to rename the final EXE file. Doing this using the approach above did not work for me because of the DLL name conflicts. My scenario uses Jenkins as the CI tool, and I ended up adding a Windows Batch command at the end of the process that renames the $PROJECT_NAME exe only.

Sunday, April 30, 2017

.NET built in function to convert string to into Title Case

Although a simple task, I was exposed today (here) to a built in function in the framework that does the job.


string title = "war and peace";

TextInfo textInfo = new CultureInfo("en-US"false).TextInfo;
title = textInfo.ToTitleCase(title); //War And Peace

Wednesday, March 8, 2017

Adding a property to a json object (either at the beginning or at the end) using Newtonsoft

Somewhere in my app I receive a JSON object, and I needed to add to it a couple of additional properties. Appending them turned out to be pretty straightforward. To add them to the beginning was not that quick.

Here's the code that does both:

string json = @"
{
    a: '123',
    b: 'avraham',
    c: { c1: 1111, c2: 'dada' }
}
"
;


var jsObject = JObject.Parse(json);
jsObject.Add("newProp", JToken.FromObject("I am a form title"));

Console.WriteLine(jsObject.ToString(Newtonsoft.Json.Formatting.Indented));
Console.WriteLine("------------- Adding property to the beginning of JSON  -----------------");

/* ------ does not work ------*/
//jsObject.AddFirst(JToken.FromObject("{formTitle: 'aaaaa'}"));
//jsObject.AddFirst("d2d2d2");
//jsObject.AddAfterSelf(JToken.FromObject("{formTitle: 'aaaaa'}"));

JObject newJObject = new JObject
(
    new JProperty("formTitle""I am a form title"),
    jsObject.Properties()
);
Console.WriteLine(newJObject.ToString(Newtonsoft.Json.Formatting.Indented));
Console.WriteLine("--------- Merging two JObjects (if the properties exist, they will be replaced/overwritten, if not, added ----------");

JObject jObjII = JObject.Parse("{x: 'x Value'}");
jObjII.Merge(jsObject);

Console.WriteLine(jObjII.ToString(Newtonsoft.Json.Formatting.Indented));

Output:


Sunday, March 5, 2017

Stop Hot Keys for Input Language Automatic Changing/Resetting

Windows 10 introduced a very annoying "feature": automatically reset your hot keys for input languages.

And the solution is not at all intuitive. Here's what you need to do (solution taken from here):



  1. Region and Language Settings
  2. Additional Date, Time & Region Settings
  3. Change input methods (under Language)
  4. Advanced Settings (Left menu/options)

Then click on "Apply language settings to the welcome screen, system accounts and new user accounts", under section "Override for Windows diplay language".

Sorry providing the walkthrough in a textual way. Too much screens to screenshot this time...

Thursday, February 23, 2017

At-First-Glance Comparison between Xamarin and React-Native

I am nothing more than a beginner in mobile development, but I am leaving here my impressions after being assigned the task of setting up a dev environment in both Xamarin and React-Native and share what it felt like to create a hello world app and play a bit with the source.



Wednesday, February 22, 2017

Setting up a React-Native dev environment in Windows 10

After days trying, alternating sighs with enthusiastic exclamation marks, I... formatted my computer, threw all my coins in the fountain, and was set to try it for one last time.

This time heavenly miracles agreed to intercede in my favor, so I ended up running the Hello World app.

This post has one sole objective (apart from occasionally hinting that you should only try mobile development (I was assigned the task in my company to try Xamarin before) if you have given up all your dreams about computer science):

Following the official docs instructions should be enough to get you there (the time frame required is, on purpose, not mentioned, neither in their docs nor here. Otherwise no one will ever try it).
You will run into config problems, missing environment variables, but you should be able to get around.

The thing is: the only real successful setting that worked for me is:
  1. Running the app not from another command prompt, as suggested by the docs, but from Android Studio itself. When asked, pick the emulator of your choice
  2. Opening a command prompt, and running react-native start...  and... it works ! (All right, it does not crash fits better)
  3. To "develop", "simply" edit the project's android.js file. 
  4. After editing your js sources, you do not have to shut the emulator, rebuild the app with Android Studio, re-start react-native packager... you can leave all up and running - just hit R + R after focusing in the emulator so the app is rebuilt and refreshed.
Congratulations, we are now on the same boat.
You are welcome to leave a comment advising leading where to.

(I like the complete appocalipytic tone of this post. It came to life after some highly frustrated days :)

Wednesday, February 15, 2017

Why Edit and Continue is not working even though it is marked in Visual Studio ?

Because it is supported only in projects that has framework versions greater or equal to 4.5.1 (from here).

AND - your scenario is likely one of the following:


Tuesday, January 3, 2017

Numbering the result set records in mysql (oracle like ROWNUM)

Here's a nice stackoverflow answer as to how to display row numbers in a mySql query. (I am perplexed how is this a missing feature both in mySql Workbench and in the proprietary sqlYog).

Seems you can declare variables within queries and use them, on the fly. You may need, this, someday.