Tuesday, July 31, 2012

Running NUnit against 32-bit, .NET 3.5 assemblies


I recently ran across a problem at work with the latest version of NUnit's GUI test runner and its VS2010 plug-in.

No matter what I tried, the test would either fail to load (see the dialog box below) or one of them would consistently throw the following exception:

System.IO.FileLoadException : Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.”

The culprit turned out to be a set of referenced assemblies that still target the 32-bit, .NET 3.5 framework.

So, that's easy, right? Just recompile the referenced assemblies to target .NET 4 and upgrade the targeted platform to x64 in Visual Studio, right?

Not so right in this case.

That solution is great if you have control over the assemblies you reference. I did not and thus had to find a way to make them work.

Solution Part #1: Run the 32-bit version of NUnit.
This should seem like a no-brainer, except for one very important detail.

nunit.exe is  a 64-bit app. Like any installation of a 64-bit app on a 64-bit system, all the Windows shortcuts target the 64-bit executable.

However, unlike a 64-bit app, NUnit installs itself in the "Program Files (x86)" file folder.

Thankfully, the 32-bit nunit-x86.exe is included. Once I redirected all my shortcuts to this file, I was able to load the test assemblies.


Solution Part #2: Add the necessary runtime and startup elements to the NUnit config files.
Once all my tests loaded I thought I had it made. Everything started along swimmingly until one of my tests began to fail, and fail consistently, with the "FileLoadException" mentioned above.

This was a head-scratcher. Every other test passed without trouble; it was just one test. Nothing was out of the ordinary in terms of the assemblies referenced by its test class.

Further research indicated that users of the the System.Data.SQLite assembly frequently encountered this exception in .NET 4 environments (such as my test assemblies).

System.Data.SQLite was in my referenced assemblies. Given what I knew at the time about our code base, I knew that it was used in some situations, but not all. After examining my test closely and stepping through some of the referenced code with a decompiler, it turned out the SQLite assembly was indeed the culprit.

So why did the SQLite assembly cause problems while the other references had no issues? The answer is actually in the exception message:

"Mixed mode assembly is built ..."

What is a mixed mode assembly? Simply put, it's a code assembly that contains both non-native, managed code (the kind of code you would generally code in, like C#, C++, or C) and native x86 instructions (really low-level stuff).

A brief scour of the internet gave me a solution--replace the SQLite assembly with one specifically targeting .NET 4.0.

Sound familiar?

In this case, three strikes were against me. I attempted to run code
  1. in a .NET 4-targeted test project and .NET 4 environment
  2. with an assembly that contained native x86 instructions while on an x64 system
  3. which required assemblies targeting an earlier version of .NET.

Even worse, I had control over none of the target frameworks. Once you've established the target framework for your test projects, you can't downgrade it.

Thankfully, one of the posts on the Logos Code blog provides the solution. It’s specific to MbUnit, but the fix also works for NUnit as well. Just find the nunit-x86.exe.config file in the NUnit directory and make the changes as detailed in the post.

To really be cool, though, you’ll also want to apply the fix to the NUnit runner extension for Visual Studio. To do so:
  1. Download the extension if you haven’t  (Tools => Extension Manager => Online Gallery => Search ‘NUnit’ => Download).
  2. Close Visual Studio.
  3. Navigate to ‘C:\Users\%USERNAME%\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Tommi Laukkanen %2F BubbleCloud.org\Visual Nunit 2010\1.2.4’.
  4. Create two new config files, “Visual NUnitRunner.exe.config” and “Visual NUnitRunner32.exe.config” and save them in the above directory.
  5. Restart Visual Studio.

Not only will that help ensure backwards compatibility of your GUI test runner, it will help ensure it for the extension as well.

Tuesday, June 26, 2012

Faithlife Study Bible—A New Way to Study Scripture


I don't often use my blog for promotions, but I'm shamelessly plugging this since I was involved in its development.

My employer, Logos Bible Software, has developed a study Bible like no other. The Faithlife Study Bible is entirely electronic, taking full advantage of what this unique medium has to offer.

  • Constant growth. Currently at 1.4 million words of notes and articles with more still to be added!
  • Tailored layers of depth. Contains three layers of study notes:


    • Quick Study layer—for quick, "at a glance" study.
    • Background layer—for more extensive background.
    • Scholarly layer—for in-depth, scholarly treatment from other popular Bible reference works (accessed via your Logos Library).


  • More than just words. Comes with nearly 400 photos, videos, and infographics (and more coming!) 
  • Built-in reference dictionary. Includes a complete Bible dictionary with 2,700 articles and 1.5 million words (also still growing).
  • Integrated. Works with seven different Bible translations—including the free Lexham English Bible, a literal translation from the Greek and Hebrew (the other six are sold separately*).
  • Social Networking. Perfect for groups—you can connect with others studying with you via notes, questions, and reading plans.
  • Versatility. Works on your Android device, Kindle Fire, iPhone, iPad, Mac, or PC, as well as on Logos, Vyrso and the web.


All this makes FSB the world's most advanced study Bible.

What's more ...

It's free.

With the coupon code "TobySteele" you can get the Faithlife Study Bible at no charge. Just follow the directions below.

Enjoy Faithlife!

Get the Faithlife Study Bible:
1.        Go to http://faithlifebible.com/free
2.        Enter your coupon code
3.        Download the app
4.        Log in with your Logos.com/Faithlife.com account
5.        Enjoy the Bible!

Where to Download the App:


*ESV, NASB95, KJV, NIV, NKJV, NRSV. You can purchase them at www.logos.com.

Sunday, March 18, 2012

The Precipice of Singular Decision

We human beings really don’t understand how much our individual choices impact this world.

For example: this week, one of our top developers changed a method name in our code base. He updated all references, and only committed his code once he verified that everything worked. This developer is very talented and exceptional at his job. He was far from careless. 

However, the code base is used widely enough that his change disabled one of our product’s key features. Worse, there was nothing to hint anything was wrong—until one of us tried to access the feature.

Once we noticed the problem it took time for another developer to track down the source. It cost us. It would have cost us a lot more had we distributed the product. Hundreds of customers would have been affected and unhappy.

Amazing what only a few keystrokes can do.

Yet history is replete with moments like these: singular decisions that have far-reaching consequences.

Take the current status of the Middle East, for instance. The Arab Spring uprisings began with one man committing suicide after his vegetable cart was wrongly confiscated by the Tunisian police.

Or our own involvement in the region: only one individual is allegedly responsible for killing 16 Afghan civilians, including men, women, and children. And now our entire mission in Afghanistan is in serious jeopardy.

Not to mention the shot that began World War I, which directly led to World War II and the birth of the modern, industrialized society. One man, one pistol, one shot.

The Bible also contains several examples of small decisions with far-reaching consequences. David’s affair with Bathsheba (2 Sa 11). Solomon’s decision to marry foreign wives (1 Ki 3:1). Esau’s sale of his birthright for a bowl of stew (Ge 25:29-34). Had the devil succeeded in tempting Jesus in the desert (Mt 4:1-11; Mk 1:12,13; Lk 4:1-13), it would have been catastrophic for humanity—a catastrophe on par with Adam and Eve’s original sin (Ge 3:1-7).

Granted, these are all extreme examples of maliciousness, not the mundane blasé of everyday living. Intent doesn’t discount them—they are still small motions that changed the world.

Yet despite of our foolish decisions, God still knows how to turn them around for good. Judah’s decision to sell his brother Joseph into slavery (Ge 37:25-28) helped save thousands of lives and laid down the beginning of Judaism. David’s affair with Bathsheba produced the bloodline from which Jesus descended (Mt 1:6). Though our sin runs amok, God’s grace is still there, mitigating the damage. He remains patient with us, “because he does not want any to perish, but all to come to repentance” (2 Pe 3:9).

I can never be sure that any of my own decisions will not have far-reaching catastrophic consequences. Yet neither can I live my life in constant fear that I might hurt someone inadvertently. Every choice I make, mundane or no, affects others.

It’s almost as if God has designed our world to work this way in its fallen state. I have to trust that even in my unknown sins, God is bringing good for all. The more I understand that, the more thankful I am when he shows me grace The more patient I am when He chooses not to protect me so I can learn from my mistakes—just as any loving father would do.

It gets even better.

God clearly does not abandon us to our messes. Yet neither will he force us to live with them forever. One day, our exile will be done, and He will wipe all tears from our eyes (Re 21:4). We will truly be able to live without the chance that we might hurt others around us.

Our world will be transformed into what it was originally meant to be: humans fellowshipping with each other and with God and loving one another forever and ever.

Wednesday, March 14, 2012

LinqPad

I am really enjoying LinqPad.

It's not often that I find myself using an IDE outside of Visual Studio. If I do, it's almost always for necessity. VS is primarily geared for full-fledged application development with Microsoft-developed coding languages. There's very little (if any) support for other, open-source languages  like Python or Javascript.

VS is also cumbersome when all you need is just a quick, simple script to manipulate XML. VS requires a lot of boilerplate for even the simplest code to run.

After a while, using VS in my day job starts to feel like a repeated exercise in futile over-engineering.

Really unfortunate, since VS has many features that I've found indispensable when coding any language (auto-completion especially come to mind).

Linqpad turns out to be a solution to that. It's a best-of-both worlds compromise. And it's quickly becoming my preferred tool of choice for quick, simple scripting in C# (of which my job requires a lot).

It supports C#, the .NET framework, and Lamda expressions, which are extremely useful when using the System.XML.Linq assembly.

External assemblies are easy to reference (even easier than VS in some ways) and the full version provides auto-complete. You don't even need to create any solutions--perfect when all you need is a few lines of code.

If you're looking for some run-time debugging or testing support, Linqpad isn't really designed for that (and sometimes could really be useful--especially on those delegated MatchEvaluators!).


However, regexes are rarely the best answer for XML. It's usually faster and easier to use LinqPad with an XML DOM rather than contrive a regex for specific XML elements.

Microsoft gets credit for helping serious developers create serious applications. But LinqPad gets extra credit for giving us novice developers a leg up in doing our (hopefully temporary) day jobs well.

Thanks, LinqPad.

Friday, March 02, 2012

The Husband Hammer

It seems single men my age get hammered hard these days. Not that many of us don't deserve it.

However, I'd like to address a particular blog post I came across recently: Warning: Rant Enclosed

As a once-married, now single male, I find posts like these highly discouraging. I live in a world that expects me to be a knight, yet also bombards me with portrayals of men as clowns, idiots, hypocrites, deadbeats, abusers, perverts, and murderers. The messages of the world are negative enough, and many of us have enough reminders of how "unmanly" we are.

The Church doesn't need to add to that weight as well.

Ruth, how can you say that my reluctance to move forward in a relationship puts me "in the loser column with a capital L"?

I'm like any other human being--I still long for the togetherness and fulfillment that a marriage relationship brings. My marriage ended badly; can you blame me if I think twice before swimming again? How many other men struggle just like your sister?

Just because I may reserve myself because of recent history does not mean that I need to "grow a pair."

I understand how unworthy for a mate that I am. Further, I also understand that I could never be worthy on my own. I am a sinner (Rom. 3:23), and I could never make myself a righteous man of God (Rom. 3:10). 

There is only one who can do that. It is Christ, and Christ alone:

“And you, who were dead in your trespasses and the uncircumcision of your flesh, God made alive together with him, having forgiven us all our trespasses ...” (Col. 2:13, ESV)

I'm not interested in making myself worthy of a mate. I'm interested in the change that Christ can bring about in me. If that makes me worthy of a mate in the long run, wonderful.

Until then, please keep your peeves about men who lack initiative to yourself.

Blessings,
A man trying to heal.

Tuesday, June 30, 2009

Life and Perelandra

I realized tonight that the whole world, both in general but particularly in the sphere of social interaction, feels to me like the surface of Perelandra.

Perelandra is the title of the second book in C.S. Lewis' space trilogy. It's also the name of the planet that Ransom is transported to.

Its surface is unlike anything on Earth. It's covered with vast, endless oceans, and any land masses are little more than giant lily pads floating on the surface of the water. They swing, bob, and undulate just as the waves of the ocean do, and while they are strong enough to support Ransom's weight, it takes quite a bit of practice (and a few bouts of sea-sickness)before he is able to walk on the surface without trouble.

Interacting with people, and for the most part, much of the world, feels to me like learning how to walk on Perelandra. It's alien. It's foreign. I don't adapt well to changing situations or unfamiliar situations--I even have an almost neurotic aversion to finding junk (read: rocks, toys, etc.) under my feet. If I can't have both my feet flat on the ground, my top-heavy nature takes advantage of me.

So much of my life has been living in a sort of manufactured Earth, so to speak, where everything is familiar and comfortable, even if detrimental. I'm comfortable when I'm alone in my thoughts, even though I despise the isolation. I'm comfortable when I can be given a task and just asked to do A, B, C, D, etc. and have it all spelled out, but then that simply makes me stagnant and unwilling to grow.

I've lived so long taking my cues from others and submitting to what they want because it is comfortable. I ride the ripples made by others' steps in this crazy world, choosing to drift along. In that place, there is a minimum of risk, a minimum of effort required, and a minimum of culpability. But there is also a minimum of freedom and a minimum of enjoyment.

Some of us seem to know how to suck the marrow from life, and I'm constantly amazed at how effortless it is for them. I'm one of those who has to really work at it, and I don't find it easy. Fear is the biggest obstacle. Not so much fear of being made a fool or making mistakes, but fear of being made a fool and making mistakes forever, that I'll always be naive in the way I behave around others or in trying new things.

I don't know how someone becomes comfortable with constant change. Is it that they don't see the islands the way I do, that they feel they are walking and running on solid rock, or is it that they have mastered the Perelandra step, and are wondering why yours truly can't compensate? If the latter, I am at a loss to understand why he has such difficulty.

Saturday, June 13, 2009

Notes on forgiveness

Been contemplating forgiveness lately. I've gone through the topical search on Libronix to find verses that discuss forgiveness, and this is what I've come up with so far. An attempt and cohesion in the form of an actual article may come later, but I thought it would be interesting to share the notes I wrote as I read through Scripture. Comments welcome.


1) we know it must always happen, as often as injury is done (Matt. 18:22, Lk 17:4)

2) it must be done even when there is little benefit for the one forgiving (Lk 23:34--Jesus dying on the cross)

3) we know it is commanded--not forgiving is sinning (Mk. 11:25)

4) not forgiving can become a hindrance when relating or worshiping our creator (Mk. 11:25).

5) forgiving can be releasing the quest for justice to God's hands (Ro. 12:19)

6) forgiving another person mimics God's forgiving nature, and is therefore a testimony of it (Lk. 6:36)

7) We must forgive those who sin against us if we expect God to forgive us (Mk. 11:25)

8) We must forgive those who sin against us because God forgave us. (Eph 4:32, Col 3:13)

9) (Parenthetical) there is so much about what we must do with forgiveness, but nothing really defining exactly WHAT forgiveness is.

10) A form of forgiveness (if the translation is correct) can be overlooking an offense (Pr 19:11). IOW, if someone cuts you off in traffic, choosing to not get angry and confront them about it when they pull into the gas station (what good would that do anyway? In that case, it's not only glorious to the person overlooking, it's just practical, particularly with small stuff like this).

11) Forgiveness and kindness are linked hand in hand (Ge 45:5-11, Ro 12:20). Is it you offer kindness--and that is your forgiveness, or do you forgive in order to offer kindness? Is it both? Either way, I think kindness for the other person can both be a sign of and a gateway towards forgiveness.

12) Forgiveness involves prayer for the one who has done you injury (Mt. 5:44). This can be lumped in with kindness. If you either forgive your enemy or are learning to, you must pray for them. What better act of kindness can you bestow than to entrust them into God's hands, and trust that his extensive love and patience for sinners, which is far greater than ours, may bring them to repentance?

13) Forgiveness of others solicits God's forgiveness for our personal sins. (Mt. 6:14,15, Lk 6:37, Jas 2:13).

14) Forgiveness means the cancellation of sin. The consequence of it (spiritual? physical? intellectual?) is no longer on the perpetrator to be paid or endure it.

15) It is imperative to forgive, because God can use anything, even evil for his glory (Ge. 50:20, 21). To not forgive demonstrates a lack of trust in God's power and control over his creation.

16) One of the reasons the most notable men of Scripture are the most notable is because of their capacity to forgive (Ge 50:20,21, 1Sa 24:7, 2Sa 18:5, 19:23, Ac 7:60, 2 Ti 4:16)

17) Forgiveness means loving your enemy (Ex 23:4, 5, Prov. 24:17, 29). It means saving him or her in their time of need (Prov. 25:21, 22). Forgiveness means showing mercy to the one who injured you (Mt. 5:7). Loving your enemy means submission (Mt. 5:39-41) to him or her, even when they do evil against you--but it is more than reluctant submission to what is merely required. It means going above and beyond what they unfairly ask of you.

18) Forgiveness of your enemy and loving your enemy is special in God's eyes (Lk 6:32-34). It sets the one forgiving his or her enemy apart from those who would only forgive a friend. Forgiving a friend is easy. Forgiving an enemy is hard. There is truth to the trite phrase, "To err is human, to forgive divine." Forgive an enemy--that is the power of God at work.

19) Forgiveness does not make light of sin. (Luke 17:3,4). Perhaps it even helps to define the evil deed as sin--why would you need forgiveness for something that is not a sin? Forgiveness may be an identifier; the victim of the evil deed, when he or she forgives the perpetrator, calls attention to the sin committed by the perpetrator and its damaging effects. It is imperative when forgiving another person that that person KNOWS what exactly he or she did that was wrong. Forgiveness in this case, is confrontational and merciful at the same time. Confrontational because it lays bare before the perpetrator what evil he or she has committed, but merciful because it brings it to that person's attention and allows them an opportunity to get right with the one the sin was committed against as well as with God. This is why forgiveness is and must be associated with an act of kindness. This is why forgiveness is and must be accompanied by prayer for this person. Because just as much as you are handing over your quest for justice over to Him, you are showing mercy to the one that wronged you by showing him/her that their hope lies with God, not with your own heart. Our hearts are not big enough. God's is. By telling someone that they wronged you and telling them you forgive them, you are essentially witnessing to them, and telling the truth of to whom they now must turn to make things right.(I could use other verses to support this idea. Anyone?)

20) Forgiveness can mean re-directing punishment or conequences away from the one who deserves it onto someone else (Philemon 18, Jesus' death on the cross). God forgives us because Christ died to pay the debt.

21) Forgiveness is an act of worship, and it shows that we are submitting to God's will. We are recognizing his holiness and recognizing our brokenness at the same time (Ge 50:19-21).

Sunday, April 12, 2009

Watchmen

Alan Moore has a healthy fear of seeing his work adapted to film—generally, he’s chosen not to be associated with any adaptations of his work, and after seeing Watchmen on film, I think I understand why.

It’s not that Watchmen isn’t successful in delivering the heart of the graphic novel to its audience. The original work’s contemplative nature is captured perfectly—the struggle with believing in lofty ideals while amorality and depravity permeates the world around us and the human nature within us.

Just capturing the novel’s heart, though, isn’t enough. It has to remain the focus, and that’s where Watchmen’s latest choice of medium begins to fail it. Watchmen the original novel is incredibly violent. When filtered through ink and paint, it’s a backdrop, a supporting element to the story’s overall conundrum. Amplified by the raw power of 21st century cinema, every blood spatter and splintered femur with all their gory sound effects simply drown out the story’s original purpose. The film becomes more about the action, not about the essence of its source.

Further, Watchmen as a graphic novel contains more richness than any film can really provide. No comic book is simply the storyboard of its adaptation. The novel’s frames are beautifully drawn, but Watchmen the film falls flat in this area. Each shot either statically replicates the original without ingenuity or defaults on conventional cinematography. Not to mention all the additional little garnishes and seasonings in the art and story that a cinema adaptation can’t include because of time and budget.

Unlike other comic book films like The Dark Knight, Watchmen doesn’t have the life it truly deserves. It tries so hard to be its source yet can’t keep from tripping over itself. In the end, Watchmen as a film misses out on opportunities to grow into something unique and separate. It’s a cold, industrial adaptation that’s probably better for home viewing than experiencing in the theatre.

Or better yet, read the book instead.