473,804 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'CorBindToRunti meEx' and STAThread attribute

Hi,

I am using ‘CorBindToRun timeEx’ To create a runtime host and execute an
assembly:
hr = CorBindToRuntim eEx(. . .)
hr = spICorRuntimeHo st->CurrentDomain( &spUnk);
spIAppDomain = spUnk;
spIAssembly = spIAppDomain->Load_3(saRawPE Image);
.. . .
spIAssembly->EntryPoint->Invoke_3(vtMis sing, 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 ‘CorBindToRun timeEx‘ 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 3135
http://blogs.msdn.com/adam_nathan/ar.../18/56727.aspx

Willy.

"Nadav" <Na***@discussi ons.microsoft.c om> wrote in message
news:79******** *************** ***********@mic rosoft.com...
Hi,

I am using 'CorBindToRunti meEx' To create a runtime host and execute an
assembly:
hr = CorBindToRuntim eEx(. . .)
hr = spICorRuntimeHo st->CurrentDomain( &spUnk);
spIAppDomain = spUnk;
spIAssembly = spIAppDomain->Load_3(saRawPE Image);
. . .
spIAssembly->EntryPoint->Invoke_3(vtMis sing, 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 'CorBindToRunti meEx' 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
1375
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 STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST? 2. If I start the default domain using STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, create a child AppDomain using LoaderOptimization.MultiDomain, and then load a non-strong named assembly into the Child Domain, does it get loaded...
11
43204
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
2189
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
6333
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 the attribute for the Main() function, I get "access denied error", if I use a ManagementEventWatcher to connect to the local machine to receive events. Is there anybody out there, how possibly can explain why this happens?? If I remove this...
1
8432
by: Alberto | last post by:
What's the meaning of the STAThread attribute? Thanks
2
3102
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
19474
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 on this problem, anything I read on the NET goes too far above my head to be of any use. For instance typical explanations say things like... 'The STAThreadAttribute marks a thread to use the Single-Threaded COM Apartment if COM is needed'
0
2882
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 2.0 and MSXML 6.0. I get HRESULT 0x80131700 when I try to call CorBindToRuntimeEx() to load the .NET Runtime from inside the shim dll. Any ideas about software or updates that I have to install ?
3
7397
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 (Upload Form) which upload the data file to our server. It used to work fine before I added remoting part into it (to make it able to communicate within TCP network). The problem is, when my application tries to show the upload form, it throws this...
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.