SDK sample OfficePlanSample - cannot compile

S

snesbitt76

Hello,

I am new to Visio development and have trouble getting started with the
Visio 2003 SDK samples. I am very interested in exploring and
expanding on the concepts of the OfficePlanSample provided with the
SDK.

My first issue is I simply can't compile this sample. Compilation
errors include not being able to resolve the following
namespaces/objects:

- Microsoft.Office.Interop
- IVisEventProc
- Shape
- AxMicrosoft
- Document
- Application

I have not changed any namespaces or import statements in any cs file.

In my project references, I have the following:

- Microsoft.Office.Core (Microsoft Office 11.0 Object Library)
- stdole
- System
- System.Data
- System.Drawing
- System.Windows.Forms
- System.XML
- Visio (Microsoft Visio 11.0 Type Library)
- VisOcx (Microsoft Visio 11.0 Drawing Control Type Library)

I have Visio Professional 2003 and am using VS.NET 2005. I also have
Microsoft Primary Interop Assemblies 2005 installed.

Can anyone notice any components or project references I am missing?
Has anyone got this sample compiled and working locally? Any and all
tips will be greatfully accepted.

Thanks in advance

Steve
 
S

Shahzad Godil

This is common error which every developer is getting first time. Just add
one new form this in this same OfficePlanSample project and place Visio
ActiveX control on that form. This is required to do just first time.
Next time, it will run without any problem even in other projects too.

Thanks
Shahzad Godil
Visio Development Blog
http://blog.360.yahoo.com/blog-iBc6GAcic6dLwZh71o.AA.Qb7wo-?cq=1
MSN Messenger : (e-mail address removed)
EMail : (e-mail address removed)
 
S

snesbitt76

Hi Shahzad,

Thanks very much for your reply. Sorry, but I cannot follow your
instruction. I dont have a Visio ActiveX control in my toolbox. Can
you please provide step by step instructions for achieving this.
Sorry, but I am a complete novice in this area.

Thanks for your help

Steve
 
S

snesbitt76

OK, well I have created a new project and copied the source from the
sample into the new project and it compiles ok. Getting the sample
code to run however is proving just as difficult and frustrating.
What's the point of shipping samples that dont work Microsoft? That's
my pointless question for the day. Humph.

Time for a break ...
 
S

Shahzad Godil

Here are easy steps for running OfficeSample if it is not running.

1. Open OfficePlanSample project
2. Add Visio ActiveX control in toolbar
3. Add a new form in this project and place Visio ActiveX.
4. Compile project, it will compile without any compilation error.
5. Now delete that new form which you created.
6. This is required only first time on each machine.

This case is mostly required on our development environemnt too. Seems
like it is generating its few interop dependents file on first time drop.

Shahzad Godil
 
S

snesbitt76

Shahzad,

Thanks for the additional info - I appreciate your time.

I have solved the compilation issues and am now battling with a runtime
issue. I am getting a COMException that is thrown when the document
events are being setup using the addAdvise(). method. The following
code fails in the sample EventSink.cs.

(line 213)
// Add the shape-added event to the document. The new shape
// will be available for processing in the handler. The
// value for VisEventCodes.visEvtAdd cannot be
// automatically converted to a short type, so the
// unchecked function is used. This allows the addition to
// be done and returns a valid short value.
newEvent = documentEvents.AddAdvise(
(unchecked((short)VisEventCodes.visEvtAdd) +
(short)VisEventCodes.visEvtShape),
(IVisEventProc)this, sink, targetArgs);

// Add the before-shape-deleted event to the document. This
// event will be raised when a shape is deleted from the
// document. The deleted shape will still be available for
// processing in the handler.
newEvent = documentEvents.AddAdvise(
(short)VisEventCodes.visEvtDel +
(short)VisEventCodes.visEvtShape,
(IVisEventProc)this, sink, targetArgs);

Even if I comment out the first addAdvise call with the visEvtAdd, the
second call with the visEvtDel also throws the same error. The
exception simply states that a COMException occured but there is no
hint as to what can be done to solve it.

Has anyone encountered this before? I'm open to any and all
suggestions as I am pretty much stuck at this point.

Thanks in advance

Steve
 
S

snesbitt76

Exception details as follows:

at Microsoft.Office.Interop.Visio.EventListClass.AddAdvise(Int16
EventCode, Object SinkIUnkOrIDisp, String IIDSink, String
TargetArgs)\r\n
at WindowsApplication1.EventSink.setAddAdvise() in EventSink.cs:line
231\r\n
at WindowsApplication1.EventSink.AddAdvise(Application
callingApplication, Document callingDocument) in EventSink.cs:line
102\r\n
at WindowsApplication1.OfficePlanSampleForm.initializeEventSink() in
frmOfficePlanSample.cs:line 1552
 

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