Cannot use .NET in thread created by _beginthread_ex under IIS with Visual Studio 2003 but works wit

  • Thread starter Lionel Schiepers
  • Start date
L

Lionel Schiepers

In the code below (called from an ASPX page), does someone known why a 'System.DllNotFoundException' exception is throw when the thread created by 'cppextension::MyExtension::Test()' starts to execute the function 'managedFunc' that use .NET code ?

This piece of code works when I use Visual Studio 2002.

The same code compiled in a console application works with Visual Studio 2003.



The code executes under IIS 5.1 on Windows XP.





#pragma managed

void managedFunc()
{

System::String *s=S"";

}



#pragma unmanaged

unsigned __stdcall threadFunc( void* pArguments )

{

free(malloc(10)); // call some unmanaged functions.

managedFunc(); // call a function that uses .NET code.

return 0;

}

#pragma managed

void cppextension::MyExtension::Test()

{

HANDLE hThread;

unsigned threadID;

hThread = (HANDLE)_beginthreadex( NULL, 0, &threadFunc, NULL, 0, &threadID );

::Sleep(40000);

}


Exception:

An unhandled exception of type 'System.DllNotFoundException' occurred in Unknown Module.

Additional information: Exception from HRESULT: 0x80131524.
 
L

Lionel Schiepers

Is there anybody at Microsoft ?

In the code below (called from an ASPX page), does someone known why a 'System.DllNotFoundException' exception is throw when the thread created by 'cppextension::MyExtension::Test()' starts to execute the function 'managedFunc' that use .NET code ?

This piece of code works when I use Visual Studio 2002.

The same code compiled in a console application works with Visual Studio 2003.



The code executes under IIS 5.1 on Windows XP.





#pragma managed

void managedFunc()
{

System::String *s=S"";

}



#pragma unmanaged

unsigned __stdcall threadFunc( void* pArguments )

{

free(malloc(10)); // call some unmanaged functions.

managedFunc(); // call a function that uses .NET code.

return 0;

}

#pragma managed

void cppextension::MyExtension::Test()

{

HANDLE hThread;

unsigned threadID;

hThread = (HANDLE)_beginthreadex( NULL, 0, &threadFunc, NULL, 0, &threadID );

::Sleep(40000);

}


Exception:

An unhandled exception of type 'System.DllNotFoundException' occurred in Unknown Module.

Additional information: Exception from HRESULT: 0x80131524.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top