Friday, March 21, 2014

Installshield LE: -4340: Internal Build Error, solved (somehow)

Thanks Flexera for the complete lack of support on this error... Well, my research had me understand the following:

  • The setup build crashes at a step which should write this in the log, but doesn't:
    Searching project for extract-at-build components...
  • It's component related (ocx?).
  • In my case, I have home made components (User Controls) in my project. They may be the cause.
  • In my case, it wasn't a dependency problem.
By repeatedly cleaning and rebuilding my projects individually, the error SOMEHOW went away. I couldn't control the problem so that's all the information I have. I hope it helps.

Tuesday, February 25, 2014

Visual Paradigm: Re-register

I'm using the Community Edition. I screwed up my email address when I tried to register so I never received the activation code. Here's what their kind support team told me to do so I can register again:

Remove the VisualParadigm folder located in %userprofile%\AppData\Local 

Start Visual Paradigm again and you should see the registration form again.

Friday, February 7, 2014

DevExpress MVC: Add an enum to a ComboBox

Here is a nice extension method I did to add an enum (text and values) to a DevExpress MVC ComboBox. it might also work with other kinds of widgets.

public static void AddEnum<TEnum>(this ListEditItemCollection instance)
 where TEnum : struct
{
 foreach (TEnum tos in (TEnum[])Enum.GetValues(typeof(TEnum)))
 {
  instance.Add(Enum.GetName(typeof(TEnum), tos), Convert.ToInt32(tos));
 }
}

Then I can do this:

Html.DevExpress().ComboBoxFor(model => model.OrderStatus,
 cbSettings =>
 {
  cbSettings.Properties.Items.AddEnum<Tag.TagOrderStatus>();
 }
).GetHtml();

the "struct" type constraint limits the type that can be used as the generic type, but won't limit it to only enums. Sh*t will hit the fan if something else that an enum is used, but it's a bit too complicated to apply a real functional compile time limit.

Have fun!

Monday, January 27, 2014

C# .Net: Get the value of a static property of a generic type

I did a base type for a singleton pattern and used a generic type later to refer to a inherited type. Here is how I got access to the Instance method:

instance = (T)typeof(T).GetProperty("Instance", BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public).GetValue(null, new object[] { });

This will call the base class Instance property and return the singleton instance of the inherited T class.

It's a bit hard to explain in words... I still hope it helps someone ;)

Friday, December 6, 2013

T-SQL: Silent Select

Here is the solution I found on SO in its simplest form:

SELECT SomeField
INTO #tmpDevNull
FROM some_table

This will store the selected result in a temporary table that will simply be disposed at the end of the request.

You might also want to begin with:

SET NOCOUNT ON

So no "rows affected" message is shown.

Thursday, October 17, 2013

Apache SetEnv does not work

Are you using it for a WSGI script? If so:

The SetEnv directive will not work as it only sets per request variables in WSGI environ dictionary and not process global os.environ.
Source

Well, this took me way too long to figure out. I was trying to use multiple environments for Trac and I was using its WSGI script. I just switched to the fcgi version and everything's fine now.

I'm off to bed. I'm so gonna hate my day tomorrow...

Thursday, September 5, 2013

Apache: couldn't perform authentication. authtype not set

I had this error in my /var/log/apache2/error.log file:

configuration error:  couldn't perform authentication. AuthType not set!: /~baldho/owncloud

Since the problematic path is a user directory, I added a Satisfy Any option to my Directory directive in my /etc/apache2/mods-enabled/userdir.conf file, like so:

<Directory /home/*/public_html>
    [...]
    Satisfy Any
    [...]
</Directory>


And the problem went away.