Subscribing to app events in Addin causing issues in other apps

D

DapperDanH

I have a unexplainable but easily replicable problem.

I am developing a C# MSProject 2003 addin using the PIA.

In the OnStartupComplete method, I am subscribing to the following MSProject
application events:

applicationObject.ProjectBeforeTaskChange+=new
MSP._EProjectApp2_ProjectBeforeTaskChangeEventHandler(mspApp_ProjectBeforeTaskChange);
applicationObject.ProjectBeforeTaskNew+=new
MSP._EProjectApp2_ProjectBeforeTaskNewEventHandler(mspApp_ProjectBeforeTaskNew);
applicationObject.ProjectBeforeResourceChange+=new
MSP._EProjectApp2_ProjectBeforeResourceChangeEventHandler(mspApp_ProjectBeforeResourceChange);
applicationObject.ProjectBeforeResourceNew+=new
MSP._EProjectApp2_ProjectBeforeResourceNewEventHandler(mspApp_ProjectBeforeResourceNew);
applicationObject.NewProject +=new
MSP._EProjectApp2_NewProjectEventHandler(mspApp_NewProject);
applicationObject.ProjectAssignmentNew+=new
MSP._EProjectApp2_ProjectAssignmentNewEventHandler(mspApp_ProjectAssignmentNew);
applicationObject.ProjectBeforeAssignmentChange+=new
MSP._EProjectApp2_ProjectBeforeAssignmentChangeEventHandler(mspApp_ProjectBeforeAssignmentChange);

The addin compiles and works great.

The issue is with other applications that run outside of MSProject and try
to instantiate MSProject like:

mspApp = new MSP.Application();

This code will fail. If i remove the code in my Addin that subscribes to
the events, it works. Even stranger is that outside apps that use
Process.Start("winproj.exe"); fail as well.

This is very easy to replicate. Anyone help?

Thanks,
Dan
 
P

Peter Huang

Hi

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you have developped a MSProject
COM Addin in C#, after you double click and open the msproject, the addin
will be loaded and the addin works well. But If now you open a new
msproject by using automation or process.start, you will get error. If so
what is the exact error message?

Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think we can consider the problem as below, we open the msproject
application (by double click) and the addin will be loaded automatically,
and if we open another msproject( by double click), we will also get the
error.(because if we double click,shell will call the createprocess to run
the msproject) You may have test to confirm the issue and let me know the
result.

Also to isolate the problem, I think you may try to comment out the code in
the event handler function first to see if the problem persists.(NOTE, I
mean just remove the code while not the event handler) and then comment out
the event handle one by one to identify which event cause the problem.

I will appreciate your efforts!


Best regards,

Peter Huang
Microsoft Online Partner Support

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

DapperDanH

Peter,
Thanks for the reply. I have tried what you suggested.

I commented out the code in each event handler function and the problem
persists. The only code that was in there before was setting a boolean to
true.

I also tried subsribing to only one single event (each event separately) and
the problem persisted. There was not an event I could get to work.

The problem seems to only exist when using automation. I can double click
and launch winproj.exe or consequetive individual .mpp files without issues.

With addin installed, if someone tried to create msproject through
automation, they get the following error:

"Call was rejected by callee."
HResult -2147418111
_COMPlusExceptionCode -532459699

My only guess is a timing issue. Perhaps subscribing to the events during
MSProject Startup takes longer and the automation calls gives up too early?

Please let me know if i can provide additional information. I look forward
to any ideas.

Thanks,
Dan
 
P

Peter Huang

Hi

As you have said, from the error it seems that the project.exe (as a com
server) is too busy to respond to the call.
-2147418111 (&H80010001)
Call was rejected by callee
This error usually occurs when the server application is too busy to
respond to the client. When a call comes into the Automation Manager, it
will try to get the attention of the OLE thread for the target object. If
the thread refuses the request (normally because it is busy with another
request), the Automation Manager will pause and then try again. The
Automation Manager will continue retrying until it succeeds or times out.

Did the problem persists on all the machine? You may try to test the simple
sample(create a new addin project and advise just one event).

Best regards,

Peter 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