April 2008 Blog Posts
BadImageFormatException Errors

I've been playing with Lua Programming/Script Language and LuaInterface, because I have a need for embedding a scripting language in one of our projects.  Unfortunately, when trying to run one of the test case applications that came with LuaInterface, I was presented with a nice error shown below:


Anytime, you run a .NET application, the operating system reads the PE header information of the executable to help setup the process environment.  In my case, TestLua.exe was being setup and ran in x64 mode with an x64 runtime and failed to P/Invoke Lua's native 32-bit DLL.


In general, there are two main ways we can explicitly tell the operating system to load and use 32-bit process environments:

For applications and assemblies that you can not recompile:

  • Set the 32-Bit flag in the PE header. 

    For example, since the 32-bit flag in TestLua.exe was not set, I forced 32-bit mode by setting the 32-bit flag using CorFlags.exe:

    Start "Visual Studio SDK Command Prompt" and execute:
    CorFlags.exe /32bit+ TestLua.exe

For applications and assemblies that you can recompile:

  • Recompile using the "Target Platform" settings as illustrated here.

In practice, if you do low-level COM, P/Invoke, Win32 stuff, you'll probably need to set these 32-bit flags for your applications; however, if your application purely lives in the managed world, you won't need to do anything!

Add Comment Filed Under [ Tips & Tricks Errors ]
Paying Estimated Taxes

image Estimated taxes are an unfortunate "pay-as-you-go" tax that every sole-proprietor, LLC, and corporation must pay.  The Federal IRS want you to pay estimated taxes, if you don't you may receive a bill from the IRS for your failure to make estimated taxes.  In this blog post, I'm mostly going to talk about Corporate taxes, but some of the basic concepts apply to individual/consultants too.

Bit Armory, Inc. just paid it's first Estimated Tax. Here are some notes I pulled along the way.

What To Pay

To compute your estimated quarterly taxes, you need to calculate your yearly "tax liability" aka "taxable income".  Taxable income is the corporation's total income for the year (gross receipts, gross sales, received interest, received royalties) minus deductions (compensation, salaries paid, repairs, maintenance, rents paid, interest paid, depreciation, advertising... etc.).


Estimated Yearly Tax Liability = (Projected Yearly Income - Projected Deductions) X Your Federal Tax Rate.


If you expect to make $50,000, then your Federal Corporate Income Tax Rate is 15% (for 2008)
Publication 542 Page 17.

Estimated Quarterly Payment = Estimated Yearly Tax Liability divided by 4 quarterly payments.

Now, if your total "Estimated Yearly Tax Liability" is less than $500 then you don't need to make quarterly payments to the IRS.  However, if your "Estimated Yearly Tax Liability" is greater than $500, then you need *should* to make estimated tax payments to the IRS.

You can choose not to pay Estimated Quarterly Tax payments; however, if you do not make your quarterly payments, then at the end of the tax year after you file your taxes, the IRS will know how much you made that year and what your estimated tax payments *should* have been throughout the year based on your tax return you filed.  At the same time, the IRS knows how much estimated taxes you paid during that tax return year.  If the sum of all the estimated payments you made during the year is lower than your final tax liability on your return, then you have "Underpaid" your estimated taxes and the IRS will send you a bill based on interest for the amount you "Underpaid" your estimated taxes.  In a nutshell, that's how estimated taxes work.

There are safe harbor rules that you can use that can prevent the penalty from being applied at the end of the tax year.

State estimated taxes work the same way, check your local tax laws!  For California, the Corporate Income Tax Rate is 8.84%.


If you're a new corporation, then you have no previous years to rely on, you calculate your estimated tax based on your current quarterly taxable income.  For example, Newly formed Acme Corp. started business on 1/1/2008.  Acme's first quarter ends 3/1/2008.  Let's say Acme makes $2,000 by selling Widgets, it's operating expenses amount to $500 for Q1, so, the total taxable income for Acme Corp is $2,000 - $500 = $1,500 profit.  Projected yearly estimated income for the year is $1,500 x 4 quarters = $6,000.  The annual estimated/forecasted taxable income for newly formed Acme Corp. is $6,000 in pure profit for the year.  Because this is profit (after expenses), the IRS taxes this income/profit at 15% which amounts to $6,000 x 15% = $900.  So, Acme Corp.'s estimated tax liability for the year is $900.  Since $900 is greater than $500 (IRS minimum required to make estimated taxes), Acme Corp. is required to make estimated tax payments of $900 / 4 quarterly payments = $225 dollars.  Your yearly estimated tax should be re-evaluated after every quarter to make sure you're caught up with the right estimated payment amount.

When To Pay

Estimated taxes are due to the IRS on the 15th of every 4th, 6th, 9th, and 12th month of fiscal taxable year.  So, for 2008, calendar year corporations, due dates are 4/15/2008, 6/15/2008, 9/15/2008, and 12/15/2008.  If the due date is on a holiday or weekend, payment is due on the next business day.

Watch out! The IRS generally considers your payments on-time if you mailed it two days before the due date.  If you wait until the very last day to mail your payment and it is post marked on the due date, the IRS might not consider it paid!

How to Pay

By Mail

You can mail your estimated taxes to the IRS by Mail.  Before you submit your payment, you need to fill out a From 8109-B with your EIN and other information.  You cannot print these forms, you'll need to order these tax coupons from the IRS or pickup some from a local depository.

Tip: Be sure to get a "Certificate of Mailing" from the post office so that you have proof you sent mail on a particular day.  Don't forget to include the 8109 with your payment smile.gif.

By Walk-In Bank

You can also deposit your estimated taxes at a local depository (authorized financial bank).  You'll still need to fill out a Form 8109-B form.


You can pay estimated taxes for the current year and pay off a previous year's tax return via EFTPS.

Estimated Payments:  When making a payment on EFTPS, select the "1120 Corporate Tax form", and "Federal Tax Deposit" tax type.

Paying Tax Returns: When making a payment on EFTPS, select the "1120 Corporate Tax form", and the "Balance due on return or notice"

Also, if your corporation makes more than a certain amount ($20,000+), you're required to use EFTPS.

Useful References

U.S. Master Tax Guide Book


Estimated Tax Payments and Penalty for Underpayment


That's all!  Enough with taxes, back to programming! party0034.gif

Disclaimer: I'm not an IRS/CPA/Business Lawyer tax person, so use this information at your own risk.  If you get stuck with a huge bill tax because of the information you followed on this blog, it's not my fault!  Always make sure you're in compliance with the law and check your tax advisor

One Comment Filed Under [ Taxes ]
Differences between NHibernate FetchMode.Eager and FetchMode.Join

What are the differences between FetchMode.Eager and FetchMode.Join?  There are none!  According to the Java Hibernate docs, FetchMode.Eager and FetchMode.Lazy have been deprecated.

In NH 1.2.1 GA source code, this is how FetchMode is defined:

   15     [Serializable]
   16     public enum FetchMode
   17     {
   18         /// <summary>
   19         /// Default to the setting configured in the mapping file.
   20         /// </summary>
   21         Default = 0,
   22         /// <summary>
   23         /// Fetch eagerly, using a separate select. Equivalent to
   24         /// <c>fetch="select"</c> (and <c>outer-join="false"</c>)
   25         /// </summary>
   26         Select = 1,
   27         /// <summary>
   28         /// Fetch using an outer join.  Equivalent to
   29         /// <c>fetch="join"</c> (and <c>outer-join="true"</c>)
   30         /// </summary>
   31         Join = 2,
   33         Lazy = Select,
   34         Eager = Join
   35     }

Well, now that clears up some of my confusions... confused0078.gif

2 Comments Filed Under [ NHibernate ]