MapPoint 2004 AddIn in VB.NET

E

Eric

I have written a AddIn (implementing IDTExtensibility2 ) which opens a form
via a MapPoint command.

Dim frm As frmData = New frmData(_ds.Copy)
frm.ShowDialog()

When I press the close button the first time, the form get closed.
When I open the form again and close it, MapPoint crash without message.
Any idea why?

Thanks
Eric
 
P

Peter Huang [MSFT]

Hi

To isolate the problem I think we may try to show a normal form and then
call the dispose method on the form, because the ShowDialog is different
from Show, we need to call dispose explicitly to release the resource.

e.g.
You may try to replace the code with the code below if the problem persists.
Dim frm As Form = New Form ()
frm.ShowDialog()
frm.Dispose()

Form.ShowDialog Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemWindowsFormsFormClassShowDialogTopic.asp


Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

Eric

Thanks for answering,

I have now tried with
Dim frm As frmData = New frmData

frm.Show()

And the form will be closed by a button (frm.Close() ).



This solves now Dialog crash, but there's is still instability.

Do you have experience wtih MapPoint 2004 and a .NET AddIn?



Thanks

Eric
 
E

Eric Frost

This solves now Dialog crash, but there's is still instability.

Do you have experience wtih MapPoint 2004 and a .NET AddIn?

Eric,

Take a look at this article -
http://www.mp2kmag.com/a119--metropolitan.statistical.areas.msa.mappoint.html

Personally, I tried converting a COM add-in which with VB 6 to VS .NET
2003 the other day and gave up after a few hours.. I decided to stick
with VB 6.

Would VB 6 be an option for you? I find it so much easier for creating
a MapPoint COM add-in. MapPoint 2004 was still a bit archaic, they did
not update much from MapPoint 2002. IMHO, VB 6 is really the
development tool to use for MapPoint.

Eric

http://www.mp2kmag.com
 
P

Peter Huang [MSFT]

Hi Eric,

In addition to Eric's suggestion, what is the problem's current status? Can
you describe the problem more detailed about instability?

I did not do a lot develop in mappoint, but I do have many .net com addin
develop experience. Based on my experience, the office produce including
the mappoint is STA which is single threaded, once we open a messagebox or
a form the messageloop will run on the form or messagebox. Especially when
we use messagebox, in this way, the message loop will run on the
messagebox(modal), that is to say, now the mappoint's other message will be
pending.

Also to isolate the problem, you may try to use a common form for a test.

If you still have any concern, please feel free to post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

Eric

Thanks for the link.
I have used this example (Is also posted on the MS site)

VB6 would been an option, but now it's to late.
I have already done most of the work.
This is true. I was also looking for an event, which would catch "modifying
territories" or "modifying datasets" events.
But there are none.
I have thought that MP2004 is more advanced.
 
E

Eric

I have changed the FormDialog to a no-modal Form.
This way I have no more crashes while closing the form.

Other points where I have instability:
- Instaincing the AddIn: In the "COM AddIn" Dialog the AddIn is not marked

- When I mark the Addin in the "COM AddIn" Dialog and press ok, I have two
times the menus (OnConnection is 2 times called)

- If I have an exception in some events (for ex. Form_Load) in my form,
MapPoint crashes without comment
(I have exception handling)

- Also while closing MapPoint there's a NullPointer exception

Thanks
Eric
 
P

Peter Huang [MSFT]

Hi

The addin's load behavior is controled by the registry key.

When we register a MapPoint addin, there will be a registry key created as
below.

[HKEY_USERS\<user
sid>\Software\Microsoft\MapPoint\AddIns\MapPointTestAddin.Connect]
"FriendlyName"="MapPointAddin"
"Description"="Make a test for MapPoint 2004"
"LoadBehavior"=dword:00000003

LoadBehavior DWORD Integer indicating load behavior: 0 (None), 3 (Startup),
9 (Load on Demand), or 16 (Load At Next Startup Only)

Commonly the key will be 3 means the addin will be loaded when the mappoint
is started.

Also based on my test I can not reproduce the problems, can you give a
simple reproduce sample, e.g. you may try to build the reproduce sample
based the below test sample.(e.g. just use a simple form to simplified the
problem).
Here is my code snippet.

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;
MessageBox.Show("Addin Connected");
Form1 fm = new Form1();
fm.Show();
}

private void Form1_Load(object sender, System.EventArgs e)
{
try
{
throw new NullReferenceException("Test Exception");
}
catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top