Click here to Skip to main content
15,922,512 members
Home / Discussions / C#
   

C#

 
GeneralIE Browser and IHTMLDocument2 Pin
brian hanf9-Jul-04 9:18
brian hanf9-Jul-04 9:18 
GeneralDisable windows shortcuts!?! Pin
QzRz9-Jul-04 7:46
QzRz9-Jul-04 7:46 
GeneralRe: Disable windows shortcuts!?! Pin
Dave Kreskowiak9-Jul-04 8:47
mveDave Kreskowiak9-Jul-04 8:47 
GeneralRe: Disable windows shortcuts!?! Pin
QzRz9-Jul-04 9:04
QzRz9-Jul-04 9:04 
Generalchange bitmap resolution Pin
kendao9-Jul-04 7:25
kendao9-Jul-04 7:25 
GeneralRe: change bitmap resolution Pin
Heath Stewart9-Jul-04 8:58
protectorHeath Stewart9-Jul-04 8:58 
GeneralRe: change bitmap resolution Pin
Werdna10-Jul-04 11:19
Werdna10-Jul-04 11:19 
GeneralCOM Object Pin
FlamTaps9-Jul-04 7:25
FlamTaps9-Jul-04 7:25 
Hello,

I am trying to instantiate a COM object. However, I am having some problems with threading. When I try to instantiate it without any threading statements, as follows:

<br />
public static void Main(String[] args) { <br />
<br />
  Application.Run(new SetupCreator()); <br />
<br />
} <br />
<br />
public SetupCreator() { <br />
<br />
  ESRI.MapObjects2.Core.AxMap map1 = new ESRI.MapObjects2.Core.AxMap(); <br />
  /*....*/ <br />
  this.Controls.Add(map1); <br />
<br />
} <br />


I get the exception: "Could not instantiate ActiveX control '9bd6a64b-ce75-11d1-af04-204c4f4f5020' because the current thread is not in a single-threaded apartment." So, I did some research, and added the line

<code}
[stathread
<="" code="">

to just before main. With that there, I get "There is no source code available for the current location". I found another approach, which adds the line:

<code>
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);


and getting rid of the STAThread line. Now, with this in place, I get "Failed to set the specified COM apartment state." So, I am a little lost as to what to do. Any suggestions?
GeneralRe: COM Object Pin
MilesAhead9-Jul-04 8:17
MilesAhead9-Jul-04 8:17 
GeneralRe: COM Object Pin
FlamTaps12-Jul-04 8:55
FlamTaps12-Jul-04 8:55 
GeneralRe: COM Object Pin
Anonymous12-Jul-04 9:37
Anonymous12-Jul-04 9:37 
GeneralRe: COM Object Pin
FlamTaps12-Jul-04 10:29
FlamTaps12-Jul-04 10:29 
GeneralRe: COM Object Pin
MilesAhead14-Jul-04 14:07
MilesAhead14-Jul-04 14:07 
GeneralImpersonation in C# question, please help! Pin
garfieldlee999-Jul-04 7:00
garfieldlee999-Jul-04 7:00 
GeneralRe: Impersonation in C# question, please help! Pin
Heath Stewart9-Jul-04 9:04
protectorHeath Stewart9-Jul-04 9:04 
GeneralProperty Grid Pin
machocr9-Jul-04 6:53
machocr9-Jul-04 6:53 
GeneralRe: Property Grid Pin
Heath Stewart9-Jul-04 9:07
protectorHeath Stewart9-Jul-04 9:07 
GeneralRe: Property Grid Pin
Jay Shankar11-Jul-04 22:26
Jay Shankar11-Jul-04 22:26 
General.NET 2.0's WebBrowser control Pin
Judah Gabriel Himango9-Jul-04 6:32
sponsorJudah Gabriel Himango9-Jul-04 6:32 
GeneralRe: .NET 2.0's WebBrowser control Pin
Heath Stewart9-Jul-04 9:11
protectorHeath Stewart9-Jul-04 9:11 
Generalimplement a own shell-view Pin
Shir Khan9-Jul-04 5:23
Shir Khan9-Jul-04 5:23 
GeneralRe: implement a own shell-view Pin
Jesse Squire9-Jul-04 5:36
Jesse Squire9-Jul-04 5:36 
GeneralRe: implement a own shell-view Pin
Nick Parker9-Jul-04 6:00
protectorNick Parker9-Jul-04 6:00 
GeneralData layer DLL .Config Pin
Andy H9-Jul-04 4:58
Andy H9-Jul-04 4:58 
GeneralRe: Data layer DLL .Config Pin
Heath Stewart9-Jul-04 9:16
protectorHeath Stewart9-Jul-04 9:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.