473,406 Members | 2,710 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.

'CorBindToRuntimeEx' and STAThread attribute

Hi,

I am using ‘CorBindToRuntimeEx’ To create a runtime host and execute an
assembly:
hr = CorBindToRuntimeEx(. . .)
hr = spICorRuntimeHost->CurrentDomain(&spUnk);
spIAppDomain = spUnk;
spIAssembly = spIAppDomain->Load_3(saRawPEImage);
.. . .
spIAssembly->EntryPoint->Invoke_3(vtMissing, saParameters);

When the assembly loads I get the following exception:
Could not instantiate ActiveX control . . . because the current thread is
not in a single threaded apartment.

I have verified that the executing IL code have the ‘[STAThread]’ attribute
for it’s entrypoint function.
When executing the assembly directly through the explorer every thing works
fine, it seems using ‘CorBindToRuntimeEx‘ in the manner just described is
causing the problem. . .

What am I doing wrong here?
What may cause this error?
--
Nadav
http://www.ddevel.com
Nov 17 '05 #1
1 3116
http://blogs.msdn.com/adam_nathan/ar.../18/56727.aspx

Willy.

"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Hi,

I am using 'CorBindToRuntimeEx' To create a runtime host and execute an
assembly:
hr = CorBindToRuntimeEx(. . .)
hr = spICorRuntimeHost->CurrentDomain(&spUnk);
spIAppDomain = spUnk;
spIAssembly = spIAppDomain->Load_3(saRawPEImage);
. . .
spIAssembly->EntryPoint->Invoke_3(vtMissing, saParameters);

When the assembly loads I get the following exception:
Could not instantiate ActiveX control . . . because the current thread is
not in a single threaded apartment.

I have verified that the executing IL code have the '[STAThread]'
attribute
for it's entrypoint function.
When executing the assembly directly through the explorer every thing
works
fine, it seems using 'CorBindToRuntimeEx' in the manner just described is
causing the problem. . .

What am I doing wrong here?
What may cause this error?
--
Nadav
http://www.ddevel.com

Nov 17 '05 #2

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

Similar topics

0
by: Sean Hederman | last post by:
I've got a couple of things I'm not sure in my mind about as far as the options to CorBindToRuntimeEx go: 1. Is the default option for Windows Forms is...
11
by: warren | last post by:
Hello, Anyone can brief me what is this in front of the Main method for? and when must it be there, and when is it optional? thank you.
3
by: Justine | last post by:
hi all, i just want to know the significance of in the C# application. Why & for What reason is this used. Thanz in Advance, Justine
9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
1
by: Alberto | last post by:
What's the meaning of the STAThread attribute? Thanks
2
by: Tom | last post by:
Do we need to put the STAThread attribute on our Sub Main anymore if we are using the 1.1 Framework? See some YEAs and NEAs when searching on Google so thought I would ask here. Tom
4
by: garyusenet | last post by:
I am at a loss with this. I tried to go back to basics, and start learning all i didn't understand, starting at the top of the code file generated by VS. But I can't seem to get any sort of start...
0
by: abhimanyu | last post by:
Hi, I 've created a shim dll in VC++ that wraps a .NET assembly AddIn for Excel. The AddIn works fine on my system but throws an error when I install it on a fresh machine with .NET Framework...
3
by: PulkitZery | last post by:
Hey guys, I am stuck in a problem very bad. I am using .net Remoting for my project to communicate within the TCP network. And after the process is done I have a function that displays a form...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.