Fix Error: An attempt was made to load a program with an incorrect format
While trying to run the sample project ShellObjectWatcherSampleWPF
from the latest version of Windows API Code Pack, I came across the following problem, both in Visual Studio 2008 and 2010:
Or in a search-engine friendly way:
“Cannot create instance of ‘
MainWindow
’ defined in assembly, ‘ShellObjectWatcherSampleWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
’. Exception has been thrown by the target of an invocation. Error in markup file ‘MainWindow.xaml’ Line 1 Position 9.”
Checking the internal exception, revealed the following:
"Could not load file or assembly '
Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
' or one of its dependencies. An attempt was made to load a program with an incorrect format."
Now, when we get an error of “incorrect format”, it usually means there is a matching problem between the bitness of the project and the bitness of the machine.
Since my system happens to be x64 based, and the project was compiled as 32bit, we got ourselves a problem.
Usually, this doesn’t matter, since .NET is bit-agnostic (yet another advantage of JIT compilation), but since the project depends heavily on P/Invoke, it does indeed make a difference.
The solution is simply to go to the Project Properties | Build and change the Platform target to x64.
That’s it for now,
Arik Poznanski.
发表评论
Wow! Thank you! I continually needed to write on my site something like that. Can I include a part of your post to my blog?
If you are concerned to learn Web optimization methods then you have to read this post, I am sure you will get much more from this piece of writing concerning Search engine marketing.
wow, awesome post.Really thank you! Fantastic.
love, love, love the dirty lime color!!!
It as not that I want to copy your web site, but I really like the design and style. Could you let me know which design are you using? Or was it tailor made?
I wanted to thank you for this good read!! I definitely enjoyed every bit of it. I have you book-marked to look at new things you post
Major thanks for the post.Thanks Again. Fantastic. ventolin
This awesome blog is really interesting as well as informative. I have picked up many interesting stuff out of this amazing blog. I ad love to return again soon. Thanks!
There is visibly a bunch to identify about this. I feel you made certain nice points in features also.
This website was how do you say it? Relevant!! Finally I have found something which helped me. Thanks!
I really liked your blog article.Really thank you!
this excellent applying. After my best spouse in addition to i dugg an variety of individuals post while cogitated everybody were thinking regarding useful practical
Maybe in the future it all do even better in those areas, but for now it as a fantastic way to organize and listen to your music and videos,
Wonderful work! This is the type of info that should be shared around the web. Shame on Google for not positioning this post higher! Come on over and visit my web site. Thanks =)
My brother suggested I might like this website. He was entirely right. This post truly made my day. You cann at imagine simply how much time I had spent for this information! Thanks!
It as not that I want to replicate your website, but I really like the pattern. Could you tell me which theme are you using? Or was it tailor made?
You have remarked very interesting points ! ps nice website.
Thanks-a-mundo for the blog post. Awesome.
Optimization? I am trying to get my blog to rank for some targeted keywords but I am not seeing very good gains.
It as not that I want to replicate your website, but I really like the style. Could you tell me which theme are you using? Or was it custom made?
This is a topic that as close to my heart Many thanks! Exactly where are your contact details though?
Some really nice and useful information on this website, likewise I think the design contains wonderful features.
Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Many thanks
This blog was how do you say it? Relevant!! Finally I ave found something that helped me. Thank you!
Thanks again for the blog post.Really looking forward to read more.
Wow, great post.Thanks Again. Really Cool.
Pretty! This has been an incredibly wonderful article. Thanks for supplying this info.
Wow! This could be one particular of the most beneficial blogs We ave ever arrive across on this subject. Actually Great. I am also a specialist in this topic so I can understand your effort.
This is really interesting, You are a very skilled blogger. I ave joined your feed and look forward to seeking more of your great post. Also, I have shared your website in my social networks!
This excellent website definitely has all of the information I wanted concerning this subject and didn at know who to ask.
This blog was how do I say it? Relevant!! Finally I ave found something which helped me. Many thanks!
Thanks so much for the blog.Much thanks again. Great.
You are my inspiration , I own few blogs and very sporadically run out from to post .
This is a topic that is near to my heart Best wishes! Exactly where are your contact details though?
My brother suggested I might like this website. He was entirely right. This post truly made my day. You cann at imagine simply how much time I had spent for this information! Thanks!
Wonderful blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Thank you
I think this is a real great blog post.Really thank you! Really Great.
Wow, great article.Really thank you! Will read on
Superb post here, thought I could learn more from but we can learn more from this post.
Very informative article post.Thanks Again. Cool.
Network Advertising is naturally quite well-known because it can earn you a great deal of dollars within a pretty short period of time..
things or advice. Maybe you could write next articles referring to this article.
Thanks for sharing this first-class piece. Very interesting ideas! (as always, btw)
This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
Sweet blog! I found it while searching on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Thank you
Say, you got a nice blog post.Much thanks again. Cool.
this side of your story. I was surprised that you aren at
Really informative article.Really looking forward to read more. Really Great.
Very interesting details you have remarked, thanks for posting. Women have been trained to speak softly and carry a lipstick. Those days are over. by Bella Abzug.
I really liked your article. Really Cool.