473,796 Members | 2,690 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 3134
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
1374
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
6332
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
19473
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
9527
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,...
0
10453
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
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...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.