Updates from May, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • danielsaidi 7:26 am on May 27, 2011 Permalink | Reply
    Tags: badimageformatexception, ,   

    How to handle BadImageFormatException in NUnit 

    While I have been developing the new version of my hobby project in .NET, everything has been working great all along…until now. Apparently, NUnit thinks that there is something wrong with one of my assemblies:

    BadImageFormatException

    So far, this assembly only contains two classes, so the easiest option would be to just delete it and create a new project and hope for the best…but, I have this thing for wanting to know what is causing this problem.

    However, my ambitions were laid to rest, since deleting the two projects and re-adding the classes solved all my problems.  I would have posted a solution here, but now we’ll never know what caused this problem in the first place.

    Or won’t we?

    After writing this blog post, Mikey posted a comment that pointed me in the right direction. I must have disabled one architecture, causing the test project to fail when using the project.

    Thanks Mikey!

     
    • Mikey 11:32 pm on October 19, 2013 Permalink | Reply

      I ran into this issue today — it turned out that the project I wanted to test was set to compile as X86, but my NUnit test project was set to ANY CPU — I set them both to ANY CPU and the issue went away.

  • danielsaidi 11:22 pm on May 16, 2011 Permalink | Reply
    Tags: app store, door codes, gps, mellon   

    Mellon! is out on the App Store 

    It has taken me a great while, but now I’ve finally managed to get my act together and get my first app out on App Store. The app is called Mellon! (can you guess why??) and is an app that lets you store door codes by location.

    When you are near a door, just open Mellon! to get the door code. It is an easy and a safe solution to connect door codes to their location. You can store codes temporarily and bind them to their location once you arrive. You can also share door codes with your friends.

    It’s a quite basic app, but imo quite functional. For instance, imagine having a party and just having to share your door code with all your guests ONCE by e-mail or SMS, instead of having to answer the phone the whole evening.

    I have had the idea for so long, but it required a focused Creative Hack event at C9 to make me realize it together with great colleagues.

    Grab the app at http://itunes.apple.com/se/app/mellon-door-codes/id436691390?mt=8.

     
  • danielsaidi 6:24 pm on May 15, 2011 Permalink | Reply
    Tags: , hdd, , , ,   

    How I solved my slow iMac with constantly working HDD 

    iMac

    The mighty iMac – great once you fix Spotlight

    A couple of days ago, I blogged about that I could have managed to solve a really frustrating problem that made my iMac dead slow. Turns out that I had.

    In short, my 27″ iMac has been really (really!) slow since I bought it. The HDD was working more or less constantly, especially when starting and waking up the iMac, but also when just running e.g. Firefox. When the HDD was reading and writing like hell, the iMac went into slow motion mode. I use OS X 10.6.7 and have a BootCamp partition on which I have Windows 7 installed.

    Neither the retailer, nor the service provider (to which i sent the computer for service) nor Apple Support were able to figure out why this was…and as a matter of fact, the SP did not even confirm the slow behavior. They probably just ran Disk Utility…and managed to scratch the chassi when doing so.

    Last Thursday, however, I finally managed to solve the problem and end 6 months daily frustration. To help others out, I sent the solution to my colleagues…and instantly received a bunch of responses from equally frustrated colleagues who had the same problem without being able to solve it.

    The problem turned out to be (as discussed at https://discussions.apple.com/message/12913591?messageID=12913591) that Spotlight tries to index the BootCamp partition. When it fails to do so…it just tries once more…then once more…then…well, you understand 🙂

    The solution is to add the BootCamp partition to the Spotlight ignore list. When I did, the problems stopped immediately and my Mac is now fast as lightning. It’s an amazing difference. You may need to re-add the ignore after rebooting (I had to do it once) and maybe add a certain file to the BootCamp root, but when you have, you will be in a world of speed.

    Now, since no one (except the great people at the forum) was able to help me out with this problem, my advice to Apple is to:

    1. Fix the Spotlight bug (duh)
    2. Recognise it, so that you know what is causing something that makes your great computers sooo slow and your customers soooooooo frustrating.
    3. Recognise it, so that, when people call in in desperation, you will be able to help.
    4. Please, tell your SP:s not to scratch my monitor the next time I send it to them. It is impossible for me to prove that they did.
    If you have the same problem, I really hope that you found a solution (and some piece of mind) here.
     
    • Stinky 8:13 pm on June 28, 2013 Permalink | Reply

      Mac are crap and so are the users that prefer such a crap. EXPENSIVE SHIT that what are those machines, large screens to appeal fool people and nothing more. Dont buy that crap

      • danielsaidi 11:23 am on July 13, 2013 Permalink | Reply

        Yeah, I’d like a PC with a really small screen instead.

      • Bob 4:05 am on May 1, 2015 Permalink | Reply

        Brainwashed morons say the stupidest crap

    • observer 11:11 pm on October 21, 2013 Permalink | Reply

      Thanks for the fix, it stopped after i deleted my bootcamp partition but it is good to finally know what it was. At the time i didn’t connected it to the spotlight. Thumbs up! 🙂

      Stinky, you’re name fits you like a glove. And it’s not about Mac vs PC, it’s more about Mac OS vs Windows and in that matter Windows is pretty crappy. You can have the best hardware out there and still be stuck to an unreliable operating system which tries to copy mac os unsuccessfully.

      • danielsaidi 12:47 pm on October 23, 2013 Permalink | Reply

        Great to hear that it works well, Andrei! I am actually considering removing my Bootcap partition as well, and see if I can get my iMac to stop sounding like a percolator 🙂 It worked for a while, but now it is reading mostly all the time (but not as bad as before the fix).

    • Nikki 10:10 pm on June 2, 2016 Permalink | Reply

      Daniel, this is an awesome advice. Thanks for sharing it. Though the post is a bit old, it still holds pretty well today 🙂 Two months ago, I updated my iMac to OS X El Capitan and it was extremely slow as well. It turns out it’s the same culprit – Spotlight indexing. Fortunately, after a day, the speed went back normal.

      I too, expect Apple would fix the issue. Hopefully in one of the upcoming updates. By the way, I also have a small blog dedicated to fixing slow iMac issues, in case other readers who read your article might be interested to know, it’s here: https://www.imacslow.com/

      I welcome you to check it out and would love to know any feedback you may have on the content. Thanks again!

      • danielsaidi 8:22 am on June 14, 2016 Permalink | Reply

        Insane that the problem is still around! My disk eventually crashed as well, and with the new SSD, the iMac is completely silent and (still, after all these years) lightning fast! 🙂

  • danielsaidi 10:20 pm on May 12, 2011 Permalink | Reply
    Tags: , , , ,   

    Slow iMac about to be fixed? 

    I have been having a world of pain with my iMac 27″ (4GB RAM), on which I run Windows 7 on a Boot Camp Partition (using VMWare Fusion). It’s basically the same setup as I have on my MBP (which has 8GB RAM though), with the minor difference that the MBP is fast as lightning and the iMac is slow as HELL!

    Now, don’t get me wrong. I do not expect the iMac to be lightning fast when running both OS X and Win 7 with 2GB each, but you have to experience my iMac to know what I’m talking about. Basically, the HDD reads and writes a lot…all the time. Sometimes, it starts hammering the disc like crazy, during which the computer goes into slowmo.

    And…it does not matter whether or not VMWare is running – it’s dead slow anyway. Despite all my communication with various Mac Stores and Apple Support, no one has been able to help me…

    …until tonight, thanks to the people at https://discussions.apple.com/message/12913591?messageID=12913591

    The key concept here is that Boot Camp + Spotlight can go no no, causing Spotlight to constantly indexing the Boot Camp partition. I am almost certain (99% give or take) that this is what has been causing the slowmotion behavior for me as well.

    When I rebooted my computer, the disc was going crazy from start, as usual. As soon as I added the Boot Camp partition to the no-indexing list in Spotlight, the disk went quiet and the computer has been working SOOOO good since then. The Boot Camp exclude gets reset when I restart my computer, but I will follow the root folder file advice in the discussion and see if it helps.

    So, if anyone of the brave forum members at https://discussions.apple.com/message/12913591?messageID=12913591 reads this – thank you sooo much! You may just have ended six months of daily frustration 🙂

     
  • danielsaidi 3:30 pm on May 12, 2011 Permalink | Reply
    Tags: i18n, l12n, localization,   

    How to localize an WPF application with a resource files 

    I currently need to localize a WPF application that consists of a main application project as well as separate DLL projects that provides the app with general user controls, model classes etc.

    Many of the tutorials I found suggested using the App.xaml file to localize the application. This does not work for me, since I need to be able to localize all parts of the application, as well as the separate DLLs.

    Fortunately, it is really easy to get resource file-based localization up and running for your WPF app. Just follow the steps below…and keep in mind that the names that I use are only boring suggestions. You can go as wild as you want to when you try it out for yourself.

    Step 1. Create a WPF application

    First, create a new WPF application. I call mine…HelloWorld!

    WPF app

    An insanely complex application called “HelloWorld”

    As you can see, I also added something to localize. I chose a Button; what do you choose? Tell me in the comments below 🙂

    Step 2. Create the resource file

    Now, let’s add a resource file into which we will add our textual content.

    To separate resource files from the rest of the application, I place the file in a Resources folder and name it AppLanguage.resx.

    Resource file

    A resource file with (so far) one single parameter

    Now, go ahead and add some content to the resource file. As you can see, I added a parameter called ButtonText, which I will apply to the Button.

    In order to access the resource file from XAML, we also need to make the file public:

    Make the resource file public

    Make the resource file public

    Once this is done, let’s access the resource file from XAML.

    Step 3. Access the resource file content from XAML

    Now, let’s use the resource file parameter in our XAML file.

    Connect the XAML code to your context class by adding the following line into the Window tag:

    xmlns:Resources="clr-namespace:HelloWorld.Resources"

    After that, you can access the resource parameter as such:

    <Button Content="{x:Static Resources:AppLanguage.Menu_LoadData_All}"></Button>

    Voilá! The text is finally displayed within the button:

    The resource text is displayed within the button.

    Since we use a resource file instead of App.xaml, we can use the same resource file to translate textual content code-behind as well. Let’s try it out.

    Step 4. Access the resource content file from code

    To access resource file content from code, simply call the AppLanguage class as such:

    using HelloWorld.Resources; //Add this topmost among the using directives
    MessageBox.Show(AppLanguage.ButtonText);   //Add this code inside the MainWindow() ctor

    When we now start our application, the message box is displayed….juuust the way we want it:

    Resource file content

     
    • Ashish Jain 9:33 am on July 10, 2013 Permalink | Reply

      Really very Helpful., Thank you for the post.

    • akatran 6:37 am on December 4, 2013 Permalink | Reply

      What about design time localization. How can someone change the language while designing the XAML of windows/page or whatever?

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel