???? ID: 206076 - ????? ???????: 03 ?????? 2010 - ??????: 2.0

????? C++ ??? apartments ?? ??? ???????? ?? ?????? ???? ?? ??? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
???:Microsoft Visual C++ 2008, Microsoft Visual C++ 2005, Microsoft Visual C++ .NET 2003, ?? Microsoft Visual C++ .NET 2002 Microsoft .NET Framework ?????? ??? ?? ??? ?? ???????? ???? ?? ????????? ??? Microsoft Windows ??? ???? ?? ??? ??????? ?? ???? ??? ?? ?? ??????? ???? ????????? ????? C++ ??? ?? ??? ???? ???? ???
??? ?? ??????? ???? | ??? ?? ??????? ????

??????

Marshal.exe ?? ?? ????? ?? ?? apartments ?? ??? ??? ???????? ?? marshaling ?? ??????? ?????? ?? ?????? ???

???? ???????

????? ????? Microsoft ??????? ?????? ?? ??????? ?? ??? ?????? ??::

?? ??? ?? ??????? ?????? ??? ?? ??????? ????
??????? ????
Marshal.exe ?????? ?? ??????? ????? (http://download.microsoft.com/download/vc60pro/info2/1/WIN98/EN-US/Marshal.exe)

Microsoft ?????? ??????? ?? ???? ??????? ???? ?? ???? ??? ???? ????? ?? ???, ????? ???? ?????? ?? ????? ?? ???? ?? Microsoft ???????? ??? ?????::
119591  (http://support.microsoft.com/kb/119591/ ) ?????? ?????? ?? Microsoft ?????? ??????? ???? ??????? ????
Microsoft ????? ?? ??? ?? ????? ?? ????? ?? ??? Microsoft ?? ?? ?????? ?? ?????? ???? ??????? ?????-??? ?????????? ?? ????? ???? ?? ????? ????? ?? ?? ??.. ????? ?? ???????-????????? ??????? ?? ???????? ?? ?? ????? ??? ??????? ??????? ?????????? ?? ????? ??? ??? ???? ???..

??? Single-Threaded Apartment (STA), CoInitialize() ?? CoInitializeEx (??, COINIT_APARTMENTTHREADED) ?? ??? ??????? ???? ??? ????? ??? ??, ???? ?? ???? ??????? ?? ????????? ??? ?? COM ?? ????? ???? ?????? ?? ??? ???? ????? ?? ??? COM ?? ??????? ???? ?? ??? CoInitialize() ?? CoInitializeEx().

??? ?? ???? COM ???????? ??? ?? STA ????? ??? ????? ?? ???, ???? ???? ??? ??????? ???? ?? ???? STA ????? ?? ??? ???? ?? ??? ???? ???? ?? ?? ??? ??? ???? ?? ??? STA ?????????? ?? serialized ?? ???? ?? ??? supposed ???, ??????? COM enforces ?? ?? ?????? ???? STA ???????? (????? ???? ??? ????? ??? ??) ??? ??? ???? ?? ??? ?? ????? ?? ??? ??? ??????? ???? ??? ????? STA ????? ?? ???, ???? ???? ?? ???? ???????? ?? ??? ??, ??? ?? ???? ?????? ?? 0x8001010E HRESULT ?? RPC_E_WRONG_THREAD (????????? marshaled ???? ??? ?? ?? ??? ???????? ?? ???? ????? ????? ?? ??? ??? ???? ??) ??????? ??????? ??????? ???? ?? ???? ???????? ?? ???? ???? ??, ??? COM serialization ???? ???? ????, ?? ??? ?????? ??????? ???? ??????, ?? ??????? ???? ??? ??? ?? ???? ?????? ??? ??, ?? ?? ??????? ?? part ?? ??????? ?? ??? ?? ?????? ???

?? ??? ?? ??? ?? ???? ??????? STA ???????? ?? ?? ????? STA ????? ?? ?? ?? ?? ???? ?? ?? ???????? ?? ?????? ??? ???? ???????? ?? ???????? marshaling/unmarshaling ?? ?????? ?? ??????? ?? ?? ????????? ??? ?? ?? ??? ????????, COM makes ?? ?????? ?? ?? ????? ????? ?? ??? ????????? ???? STA ???????? ????? ??? ????? ?? ?????? ??? ??? ???????

Marshal/unmarshal ???? STA ?? ???? ???? ????? ?? ??? ??? ???????? ?? ??? ????? ???:
  1. CoMarshalInterThreadInterfaceInStream() ?? CoGetInterfaceAndReleaseStream(): ?? ???? ?? ????? ???? ?? ??? ?? drawback ??????? ???? ?? ???? ??? unmarshaled ?? ??? ??? ??????, ??? ???? ????? ???? ???????? ?? ??? ?? STA ??????? ??, ?? ???? ??? ???? ????
  2. CoMarshalInterface() ?? CoUnMarshalInterface(): ????? ?? ?? ??? ???????? ?? ?????? unmarshal ??????? ?? ??? ??? ?? ?? ??? ??? ?? ??? like; ?????? ?? ???, ?? ??????? marshaling MSHLFLGS_TABLEWEAK ?? MSHLFLGS_TABLESTRONG ????????? ?? ???? ??? ?? ?????? ???? ????? ??? ????? ??? ?? ?? ???????? ???? ??? ??? IStream ?????, ??? ???? ?? ??? ???? ?? marshal ????? CoReleaseMarshalData() ?? ?????? ?? ??? ???? ?? ??? ??? ??? ???????? ?? ??? ???? ?? marshaling ?? ?? Windows NT 4.0 ?????? ??? 4 ?? ??? ???, Windows 98 ?? Windows 95 DCOM 1.2 ?? ??? ???? ????? ?? ??? ??? ??????? ??? ?? ???? MSHLFLGS_TABLESTRONG ?? ????? ???? ??? ?? ???? ?????? Windows 2000 ?? ??? ?? ??????? ???
  3. ??????? ???????? Table(GIT): GIT, ??? ?? STA ????? ??? ???????? ?? ???????? ???? ?? ??? ???? ???????? STA ?? ???? ???? ????? ??? ????? ??????? ???? ?? ?????? ???? ?? ?? COM ???????? ??? ?? ???? ?? ?? ??? ??? ??????? Windows NT 4.0 ?????? ??? 3 ?? ??? ???, Windows 98 ?? Windows 95 DCOM 1.1 ?? ??? ?????? ???
Marshal.exe ????? ????????? ?? ?? TSTMARSH ??? ??? ?? ??? ATL EXE ????? ?? ITest ???? ???? ??? ITest ?? ?????? ToUpper(), ?? ???????? ?? ?????? ??? ?????? ???? ?? ?????? ??? ??? ??? ??????? ?? ??? ??? ??? sub-project ?? ????? ??? Client.cpp ?? ???? ??? marshaling/unmarshaling ??????? ????? ???? ???? ???????? ???? ?? ??????? ???????? ?? ??????? ????? ??, ?? ITest marshals ??????? ?? ????? ????? ??? ???????? ????? ??? ??? ITest ???????? unmarshaled ?? ?? ???? ToUpper() ?????? ?? ?? ???????? ??? ?????? ???? ?? ???? ?????? ?? ???? ????? ??? ????? ?????: "?? ????? ?? ?????? IS # N"?

??????

???? ??????? ?? ???, Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ????? ????::
172314  (http://support.microsoft.com/kb/172314/ ) RPC_E_WRONG_THREAD ?????? ?? ??????????

???? ???? ???? ??:
  • Microsoft Visual C++ 2008 Express Edition
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
??????: 
kbsweptvs2008 kbarchitecture kbfile kbhowto kbsample kbthread kbmt KB206076 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:206076  (http://support.microsoft.com/kb/206076/en-us/ )