ASP.NET和STA COM对象 [英] ASP.NET and STA COM objects

查看:106
本文介绍了ASP.NET和STA COM对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展望在此定居的参数。

我的一切使用在VB中创建一个COM对象从ASP.NET页阅读的东西与

All the stuff I've read on using a COM object created in VB from an ASP.NET page is surrounding with

警告 - 请确保你把ASPCOMPAT或将无法正常工作

<一个href=\"http://books.google.co.uk/books?id=-sjg09Crh40C&lpg=PA771&ots=g-vqDun9TR&dq=asp.net%20c%23%20sta&pg=PA771#v=onepage&q=&f=false\" rel=\"nofollow\">http://books.google.co.uk/books?id=-sjg09Crh40C&lpg=PA771&ots=g-vqDun9TR&dq=asp.net%20c%23%20sta&pg=PA771#v=onepage&q=&f=false

不过......我已经设置你猜怎么着 - 没有问题

However... I have set this up and guess what - no problems.

现在,我读这

http://msdn.microsoft.com/en-us/library/ zwk9h2kb.aspx

HTTP://blogs.claritycon。 COM /博客/不要%5Fpeterson /存档/ 2008/01/17 / 3621.aspx

这表明你不会得到一个例外,它只是将不能很好地工作。

Which suggests that you won't get an exception, it just won't work very well.

谁能给出一个明确的答案,这是怎么回事?

Could anyone give a definitive answer to what is going on?

此外,如果有任何的方式,我可以证明MTA和STA之间的切换。(通过一些调试魔法 - !连看汇编)我会很感激

Also, if there's any way that I could PROVE the switch between MTA and STA (through some debugger magic - even looking at the assembler!) I'd be grateful.

干杯
邓肯

推荐答案

当然,你可以在ASP.NET应用程序使用VB COM组件。你认为VB百万code线都不会得到的任何在.NET的土地的爱吗? :)

Sure you can use a VB COM component in an ASP.NET application. You think that millions of lines of VB code aren't going to get any love in .NET-land? :)

VB COM组件是臭名昭著的使用单线程单元(STA)被编译 - 尽管并非总是如此(如果我没记错)

VB COM components are notorious for being compiled using a Single Threaded Apartment (STA) - though not always the case (if I remember correctly).

在.NET中使用STA VB组件,你可能会发现你体验:

When using a STA VB component in .NET you might find that you experience:


  1. 性能下降

  2. 由于堵塞终结可能的内存泄漏(不试图将所有的危困,只是似乎更经常发生比不了)

  3. 脱发

这是简单的方法来确定MTA诉为STA线程是利用WinDBG的,连接的过程中,加载SOS,并执行!线程。你会看到类似的输出:

An easy way to determine MTA v. STA for a thread is to leverage Windbg, connect to the process, load SOS, and execute !threads. You'll see output similar to:

0:015> !threads
ThreadCount: 27
UnstartedThread: 0
BackgroundThread: 17
PendingThread: 0
DeadThread: 10
Hosted Runtime: no
                                      PreEmptive   GC Alloc           Lock
       ID OSID ThreadOBJ    State     GC       Context       Domain   Count APT Exception
  15    1  a28 000d75f0   1808220 Enabled  3823b58c:3823bb08 000d3fe8     0 STA (Threadpool Worker)
  19    2  43c 000dd5f0      b220 Enabled  00000000:00000000 000d3fe8     0 MTA (Finalizer)
  20    3  b94 000f20b0    80a220 Enabled  00000000:00000000 000d3fe8     0 MTA (Threadpool Completion Port)
  21    4  15c 000f5318      1220 Enabled  00000000:00000000 000d3fe8     0 Ukn

请注意,一个线程拥有的STA在APT列中列出。这线程是STA线程和你可能会看到你的VB COM code的调用堆栈上。

Note that one of threads has "STA" listed in the APT column. This thread is a STA thread and your likely to see your VB COM code on its call stack.

引用讨论的问题:

  • COM Interoperability in the .NET Framework
  • Running ASMX services on STA Threads
  • Developing High Performance ASP.NET Websites
  • ASP.NET Hang and OutOfMemoryException caused by STA Components
  • Debugging Tools for Windows

祝您好运!

ž

Good Luck!
Z

这篇关于ASP.NET和STA COM对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆