asp中無法跨session,application調用vb組件的原因

來源:互聯網
上載者:User

 

IIS是一個線程伺服器,每一個asp都是一個線程,因而跨session,application就必須滿足這一點。遺憾的是,vb是一個面向進階應用程式的開發工具,並不支援跨線程的組件,只能編寫單線程的組件。而猴版的vbs更是如此,在vbs中用class定義出來的對象一樣不允許跨線程。

要突破這一點,就必須使用vc,cb之類低級的開發工具,而其中手工定義介面,IDispatch,IUnknown,UID之類的事,讓人頭昏腦漲,即便是vs.net 2005 , cb6中 ,也似乎沒有多少改善。

下面引用cb的一段協助來說明各種組件的不同

Automation Objects can have one of the following:

Single Only one client thread can be serviced at a time. COM serializes all incoming calls to enforce this. Your code needs no thread support.
Apartment Each object instantiated by a client is accessed by one thread at a time. You must protect against multiple threads accessing global memory, but objects can safely access their own instance data (object properties and members).
Free Each object instance may be called by multiple threads simultaneously. You must protect instance data as well as global memory.

Both This is the same as the Free-threaded model, except that all callbacks supplied by clients are guaranteed to execute in the same thread. This means you do not need protect values supplied as parameters to callback functions.
Neutral Multiple clients can call the object on different threads at the same time, but COM ensures that no two calls conflict. You must guard against thread conflicts involving global data and any instance data that is accessed by more than one method. This model should not be used with objects that have a user interface. This model is only available under COM+. Under COM, it is mapped to the Apartment model.

 

希也不要太深究此問題,C程式員和asp程式員的薪水差別之大是顯而易見的,我想當真能夠用c編寫出需要的組件時,沒人捨得回到廉價的asp工程上了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.