473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Threads created in unmanaged code always use the default app domai

Hi,
I have developed an application that uses mixed C++ to integrate managed
..NET applications with an unmanaged C++ application whose behaviour I cannot
change.

The unmanaged C++ application uses the Win32 API's CreateThread fn to create
a thread that listens for requests. These requests then call into the mixed
C++ code. This all works fine when the application lives in the same app
domain.

However, in an environment such as IIS where the application lives in its
own app domain there is a problem because the thread that is being created in
the unmanaged code is using the default app domain and so cannot use the
objects created in the application's app domain. Is there anyway to get these
threads to use the applications app domain rather than the default app domain?

In my opinion this behaviour is a bug, I thought that the whole idea of an
app domain was to create a sandbox where by the main application (in this
case IIS) could run numerous applications without having to worry about their
behaviour. Yet using this method I have a thread running in the default app
domain which I assume would have the capability to bring down IIS.
Cheers,
Paul
--
Paul Kenny
Senior Software Engineer
IONA Technologies Plc.

Nov 17 '05 #1
3 2204
Paul Kenny wrote:
Hi,
I have developed an application that uses mixed C++ to integrate managed
..NET applications with an unmanaged C++ application whose behaviour I cannot
change.

The unmanaged C++ application uses the Win32 API's CreateThread fn to create
a thread that listens for requests. These requests then call into the mixed
C++ code. This all works fine when the application lives in the same app
domain.

However, in an environment such as IIS where the application lives in its
own app domain there is a problem because the thread that is being created in
the unmanaged code is using the default app domain and so cannot use the
objects created in the application's app domain. Is there anyway to get these
threads to use the applications app domain rather than the default app domain?

In my opinion this behaviour is a bug, I thought that the whole idea of an
app domain was to create a sandbox where by the main application (in this
case IIS) could run numerous applications without having to worry about their
behaviour. Yet using this method I have a thread running in the default app
domain which I assume would have the capability to bring down IIS.
Cheers,
Paul

Create the thread on the managed side.

Ronald Laeremans'
Visual C++ team
Nov 17 '05 #2
Hi Ronald,
As I said in my original post I am integrating with a legacy unmanaged C++
application that I have no control of so it is not possible for me to create
the thread on the managed side. Is this the only way to work around this
issue?
By the way is there a bug number or something associated with this? Is it
considered a bug?? Is it likely to be fixed?
Cheers,
Paul
--
Paul Kenny
Senior Software Engineer
IONA Technologies Plc.

"Ronald Laeremans [MSFT]" wrote:
Paul Kenny wrote:
Hi,
I have developed an application that uses mixed C++ to integrate managed
..NET applications with an unmanaged C++ application whose behaviour I cannot
change.

The unmanaged C++ application uses the Win32 API's CreateThread fn to create
a thread that listens for requests. These requests then call into the mixed
C++ code. This all works fine when the application lives in the same app
domain.

However, in an environment such as IIS where the application lives in its
own app domain there is a problem because the thread that is being created in
the unmanaged code is using the default app domain and so cannot use the
objects created in the application's app domain. Is there anyway to get these
threads to use the applications app domain rather than the default app domain?

In my opinion this behaviour is a bug, I thought that the whole idea of an
app domain was to create a sandbox where by the main application (in this
case IIS) could run numerous applications without having to worry about their
behaviour. Yet using this method I have a thread running in the default app
domain which I assume would have the capability to bring down IIS.
Cheers,
Paul

Create the thread on the managed side.

Ronald Laeremans'
Visual C++ team

Nov 17 '05 #3
Paul Kenny wrote:
Hi Ronald,
As I said in my original post I am integrating with a legacy unmanaged C++
application that I have no control of so it is not possible for me to create
the thread on the managed side. Is this the only way to work around this
issue?
By the way is there a bug number or something associated with this? Is it
considered a bug?? Is it likely to be fixed?
Cheers,
Paul

You can also use the .NET hosting APIs to get significantly more fine
grained control from the native side. You can take a look here for the
2.0 version of the hosting API:
http://winfx.msdn.microsoft.com/libr...a39302d922.asp

Ronald
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
5
by: adrin | last post by:
hi i have the following problem: i use functions from an external dll(normal w32 unmanaged library) which takes a structure address as an argument.. how do i pass it in c#? i tried using array...
2
by: tony lock | last post by:
I am trying to call an unmanaged dll from c#, the function is asyncronous and expects a callback function and a parameter which is labelled lpvoid but which expects the address of the calling object,...
2
by: asanford | last post by:
We use StackWalk(StackWalk64) from dbghelp.dll to walk our callstacksas needed, using the various Sym* methods (SymGetSymFromAddr, SymGetLineFromAddr) to resolve source file, function name, and...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
3
by: JoeProgrammer | last post by:
A couple of questions re. managed vs. unmanaged code. 1. I know this depends on the app, but how much faster is unmanaged code vs. managed code? Is there an average figure for this? 2. Is it as...
3
by: Thorsten | last post by:
HI I'm a C# developer and unfortunately I have to write now some code in managed and unmanaged C++. In this area I'm Newbie and therefore please forgive me if this is a really simple...
13
by: bonk | last post by:
Hello, I am trying to create a dll that internally uses managed types but exposes a plain unmanaged interface. All the managed stuff shall be "wrapped out of sight". So that I would be able to...
5
by: R. MacDonald | last post by:
Hello, all, I am currently working on a .Net (VB) application that invokes routines in unmanaged (Fortran) DLLs. The unmanaged routines then communicate with the .Net application by means of a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.