QT 与 Visual studio 2008 的集成

来源:互联网 发布:工资个人所得税算法 编辑:程序博客网 时间:2024/06/12 18:43

第一步:

 到  http://qt.nokia.com/downloads  下载 Qt libraries 4.6.2 for Windows (VS 2008, 194 MB)

      和  Visual Studio Add-in (44 MB)

第二步:

   首先安装  Visual studio 2008 (英文版)

   其次安装  Qt libraries 4.6.2 for windows (vs 2008)

   最后安装 visual studio Add-in

 

运行 vs 2008,  发现 在菜单中己经有一项 QT,在 file->new->project 中,己有QT projects的选项.

生成一个 QT project,一切默认,运行,通过. (貌似成功)

 

 满以为,真的成功了,检验各个菜单,QT->launch designer 出现大大的异常对话框

 

 

找不到 函数:  Boolean System.Treading.WaitHandle.WaitOne(Int32)

 

这让人比较郁闷了, 仔细分析一下,上面的语法,System.... 什么的,好像是C#的.

而且是QT菜单下的,那就是出在了 visual studio Add-in 上面,以前编译源码的时候,也用到了这个软件,不过是1.0的版本,

难道,,,,难道,,,就是因为新版本,用到了新的特性?  猜,只是猜测,

那就以那个函数为关键字,google一下,真发现一个类似的,

网址如下:

http://www.mikeplate.com/missingmethodexception-and-waitone/     (此页内容以防丢失,特复制,粘贴于下文)

咱外语,不强,似懂非懂,半看半猜,大概是出在了 .net framework 上面了,

进入控制面板,添加删除程序 一下,NND,己经有了三个版本,分别是:2.0sp2,  3.0sp2,  3.5 

我晕,难道3.5也有spack ?

又google了一下,  NND,还真有. 于是下载,安装. 重启机子,

重新进入 VS2008,  打开菜单,QT->launch designer,   那个心脏呀,那个跳呀.

哦,哦,漂亮的设计器出来了,大功告成.  嘿嘿,,,,,

 

有了 Qt libraries 4.6.2 for windows (vs 2008) 

再也不像以前, 下载源代码,设置一大堆选项,和环境变量,用VS2008 编译.

 

唉,想想以前编译的时候,达到7G, 最终成品600M左右, 花费3个多小时.

(以前编译的成品,还放着呢,舍不得扔)

 


 

A customer complained today about a WinForms application written for .NET 2.0 that crashed. It turns out that on the customer’s computer, a MissingMethodException is thrown when calling:

bool signal = WaitHandle.WaitOne(0);

Well, it works fine on my computer and I was certain that the project settings in Visual Studio 2008 was set to .NET version 2.0 and that the customer has that version of .NET installed. It is a system method, so it should be there, shouldn’t it?

Not so. Turns out, if I’m not mistaken here, that this a new overload of the WaitOne method that was introduced in .NET 2.0 SP2. There are several overloads of this method, and the two I was having trouble choosing between was:

bool WaitOne(int millisecondsTimeout, bool exitContext);
bool WaitOne(int millisecondsTimeout);

I must confess that I’m not entirely sure what exitContext means and the difference in supplying true or false. So out of laziness, when Visual Studio presented me with these choices, I chose the latter without the bool argument. Bad choice!

From what I understand this overload was actually added in .NET Framework 2.0 Service Pack 2. However it seems that SP2 is not installed by Windows Update and isn’t even available as a separate download. It is only available as part of .NET Framework 3.5 Service Pack 1.

You might know about the confusion about .NET Framework versions that seems to have replaced the old COM based dll hell. I’m probably not the best person to explain it and I sure use my own terminology. However, I’m going to give it a shot:

The thing is that one differentiates between the “core” .NET and “extensions” to .NET. Since version 3.0 of .NET no new versions has been created for the “core”. All libraries from version 3.0 and up are “extensions” and they all depend on the “core”. The “core” .NET is therefore still in version 2.0. However, I guess some bugs might have been discovered but also I’m guessing that while building the “extensions” a need for some updates in the “core” arised, which is why the “core” still had to be changed. And this lead to the release of service packs for the “core”. The result is that the package known as “.NET 3.5 SP1″ includes an update to the core known as “.NET 2.0 SP2″.

Anyway, there are two “fixes” for my problem:

  • Supply a boolean as the second argument to WaitOne in all my code.
  • Require .NET 3.5 SP1 to run the application.

I chose the first one.

To Visual Studio, one might request that you had warned me about this. There is a generation of warnings when building applications where you use certain classes and methods that “should not be used anymore”. I guess this is the opposite, but should still warrant a warning?

Note: Please make a comment if you have a better understanding of this issue than I have. I can’t say I have verified all my findings.

11 Responses to MissingMethodException and WaitOne

Avatar

Vaclav Kabat

October 23rd, 2008 at 14:12

my primary issue is that both dlls (before and after) have same version

Avatar

joe

January 5th, 2009 at 21:38

these new overloads stung me and I wasted many hours. they shouldn’t introduce new overloads in a service pack, if you ask me.

Avatar

Michael

February 24th, 2009 at 10:18

Mike, thanks for the info! You helped me a lot.

Avatar

listar

April 7th, 2009 at 05:54

Mike, thanks! I got a few hours of headache with MissingMethodException and finally I found your article! Thanks again!!! You save my day =)

Avatar

Luckyrat

May 7th, 2009 at 22:48

+1

Took me a while to realise this was my problem (I am calling the method via a separate unmanaged process and with my lack of C++ expertise it was ages before I even considered it could be a .NET failure).

Thanks!

Avatar

Chris

June 18th, 2009 at 16:07

+1

Wow, I spent a few hours debugging this problem, the customer had .Net framework 3.5 (not SP1) installed, it worked fine for me but not for him… I think google suggest was the biggest help, I was searching for “missingmethodexception” and it suggested that I add “waitone” to the search string, that’s how I found this article :)

Thanks!!!

Avatar

Martin

June 30th, 2009 at 15:02

Thanks Mike, this saved me a lot of time.

It seems to me that the “multi-targeting” feature of VS2008 is somewhat broken. I ask it to target v2.0 of the .NET framework, and it allows me to write code that only works in a version of v2.0 that’s deployed with v3.5.

Avatar

Peter Stephens

July 28th, 2009 at 12:27

One note: the documentation for WaitHandle.WaitOne(int) claims that it will work for .NET 2.0 SP1. This is not true as you have found out. 2.0 SP2 is required.

Avatar

MissingMethodException and WaitOne « Second Stanza

August 1st, 2009 at 17:59

[...] .NET Development — dfbaskin @ 12:59 pm I ran into the same problem as Mike Plate describes here. Fortunately, there is a now separate download for the .NET 2.0 Service Pack 2 here. Installing [...]

Avatar

DJacobs

August 27th, 2009 at 19:13

FWIW, I had a P9 system.missingmethodexception error that was crashing a simple application on some machines but not on others. I tracked it down to a “.WaitOne(2000)” line that was executing inside a thread. Never causes a problem on my machine, but it sure crashed on those other machines, EVEN THOUGH THE CODE WAS NEVER EXECUTED! The thread hadn’t even gotten to that line. The crash was occurring when the program started up, which was really frustrating. I even had a “try..catch” around the problem line of code, and it didn’t help. I stopped using the AutoResetEvent and used a variable and a “while( ! signaled ) { Thread.sleep(20); }, which was a kludge, but it worked….

Avatar

DJacobs

September 8th, 2009 at 19:07

Apparently, this error is thrown by the JIT compiler, which is why no amount of “try..catch” lines will prevent it: http://stackoverflow.com/questions/809337/net-wpf-missingmethodexception-when-launching-new-thread

 

 

 

原创粉丝点击