RE: SQL 2005 and SQL Express VS2005 July CTP Merge Replication



Hi Mike,

For the [STAThread] property to work, it must be used on the "first" method
of a thread. If you want to change the main thread of a process to be an
STAThread, you would have to decorate the Main method of the program with the
[STAThread] attribute. I am guessing that in your case, only the method
immediately wrapping the call to mPullSub.SynchronizationAgent is decorated
with the [STAThread] attribute. In any case, we can probably figure out
exactly what is going if you can post a few relevant code-snippets here.

HTH

-Ryamond


"msmith" wrote:

> When I execute
> (MergePullSubscription)mPullSub.SynchronizationAgent.Synchronize() I get an
> error {"The MergeSynchronizationAgent class must be instantiated on a
> Single-Threaded Apartment (STA) thread."}, but as far as I can tell it is. I
> even added the attribure [STAThread] and still get the error.
>
> Thanks Mike Smith
.



Relevant Pages

  • RE: SQL 2005 and SQL Express VS2005 July CTP Merge Replication
    ... > Hi Mike, ... > STAThread, you would have to decorate the Main method of the program with the ...
    (microsoft.public.sqlserver.replication)
  • Re: cross - thread problem
    ... Well, yes, you could, by calling the Invoke method on the control, and passing in a delegate which will execute the code on the UI thread. ... I notice that where the form F1 is instantiated, it also has Single threaded [STAThread] set; ...
    (microsoft.public.dotnet.languages.csharp)

Loading