Mappoint 2006, C#, VS 2008, Vista, COM object problems

jovo
11-27-2007, 01:35 PM
Hi Everyone:

I sure hope someone can help. The environment is Vista Enterprise (UAC turned off), Microsoft Visual Studio 2008 (Release, NOT orcas beta 2), Microsoft Mappoint 2006, C# language.

If I create a new windows form application, add the Mappoint COM object to the toolbox (Mappoint control 13.0), then drop it on the form, then try to run it... she fails with..

"InvalidOperationException" Cross-Thread operation not valid: Control 'axMappointControl1' accessed from a thread other than the thread it was created on.

This is like the 'hello world' of putting a mappoint object onto a form. The problem started with Orcas Beta 2 and has not gone away for myself or any of our developers. The result is our application, which used mappoint since 2004, can no longer bring up a mappoint map at all because of this failure.

For grins, I have attached this ultra simple mappoint test. Mappoint 2006 is loaded on the machine and does come up if I run it manually (As a separate program), but I can't get it to come up on a windows form at all, from anything (wheras, we had no trouble with VS 2005).

Anybody else run into this strange and bizzare interaction for the COM object in VS 2008? Any suggestions are appreciated. Thanks

Jovo

Winwaed
11-28-2007, 08:36 AM
I haven't played with VS2008 & C#, but I know that Microsoft have been busy adding multi-threading tools to the latest versions of .NET and C#. Could it be that there's a default setting changed for the form, so that it is doing what the error says? Ie. different threads are being used to create and access control?

Some of the new multi-threading stuff looks pretty neat - eg. a foreach that works a bit like the old vector processing operatives seen on Crays, Convexes, etc. Shame it will be a few years before a substantial number of PCs have it installed as standard...


Richard

Wilfried
11-29-2007, 08:41 AM
Hi,

Are you very sure you don't access any of the mappoint things from in another thread as the one where the form is created ?

jovo
12-04-2007, 03:04 PM
Hi Wilfried -

I appreciate your asking, but that is why I posted the project. The project posted is simply, create a new windows form, drop the mappoint control on the form and try to run the program. On VS 2008 (release) running framework 3.5 (release) on MS vista (32 bit, enterprise edition -- any edition fails), the cross-threading error comes up.

There is no additional coding in place. Please try the project on a vista machine with vs 2008 and mappoint. If it somehow works for you where it has failed on all 20 of our vista test environments and development machines, then I would very much like to know how to get it to work on vista.

The same project, compiled.. may run on Win XP. In particular, if I use AxInterop.Mappoint.dll generated by VS 2005 (the older vs) on an XP machine, then mappoint comes up fine on an XP machine. But not vista... the cross-threading error happens.

Wilfried
12-07-2007, 08:59 AM
Hi,

I have no Vista machine here, and still not installed VS2008. But you could try if it is indeed running in same thread using GetCurrentThreadId (which has been deprecated) or ManagedThreadId because then you can determine if it is a bug in vista or in VS2008.

theduck
06-16-2008, 05:00 AM
Hi
Has anybody found a solution for this issue sofar?
LG
Daniel

jatkins
06-18-2008, 04:46 PM
Hi, I just tried this for you in VS2008 and get the same error message as you. I googled for the error and found this which may be useful.

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.vsnet.debugging&tid=cd71c3c9-863f-456e-9887-4258d6f7f83f&cat=&lang=&cr=&sloc=&p=1

I've not tried the suggestions in VS2008 as I use still use 2005 and it sounds like the workaround may work for some and not others.

John.

 
Web mp2kmag.com
mapforums.com