المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to mark / build C# / WPF component STA



C# Programming
12-30-2009, 07:40 PM
I am hosting WPF components in unmanaged MFC. This WPF components will do some ricktext editing. Hosting / editing are working fine but closing will crash application on exit (release version only and no crash on debug). The following is the current structure:

class parentA_COM : definited / implemented in unmanaged C++, STA
class memberB_COM : definited in unmanaged C++, but implemented in C# (ComVisible)
class winUserControl: implemented in C# to host WPF user control;
class wpfUserControl: implemented in C#

class MyApp // unmanaged C++
{
main ()
{
parentA_COM pPA(); // Initialize COM component
}
}

class parentA_COM // unmanaged C++
{
void get_hWnd()
{
m_ipMB.CreateInstance(xxx);
m_ipMB->get_hWnd();
}

private:
memberB_COM m_ipMB;
}

class memberB_COM : IDisposable, ... // C#
{
constuctor // initialize winUserControl
}

class winUserControl : UserControl
{
host WPF control wpfUserControl
}

How can I mark / make wpfUserControl / or winUserControl / or memberB_COM STA? Thanks.