This project has moved. For the latest updates, please go here.

Errors when build runs on different machines: Microsoft.Office.Interop.Visio.Application application = new Microsoft.Office.Interop.Visio.Application(null, visioProxy)

Aug 31, 2015 at 4:46 PM
Edited Aug 31, 2015 at 6:03 PM
The solution and project have the package NetOffice Core and visio installed. This line:

Microsoft.Office.Interop.Visio.Application application = new Microsoft.Office.Interop.Visio.Application(null, visioProxy)
Type visioType = Type.GetTypeFromProgID("Visio.Application");
object visioProxy = Activator.CreateInstance(visioType);
Microsoft.Office.Interop.Visio.Application application = new Microsoft.Office.Interop.Visio.Application(null, visioProxy);
works fine on my machine when I build but not on our build server. The error returned is: 'Application' does not contain a contstructor that takes 2 arguments.

What is our build server missing? The project has a reference to NetOffice Core Api and VisioApi

Appears that two parameters is not liked, but it builds on vs 2013 but not vs 2015?
Coordinator
Sep 1, 2015 at 6:15 AM
This can't work on any system because you have to use NetOffice instead of interop.

Replace Interop:
Microsoft.Office.Interop.Visio.Application application = new Microsoft.Office.Interop.Visio.Application(null, visioProxy);
With NetOffice:
NetOffice.VisioApi.Application application = new NetOffice.VisioApi.Application(null, visioProxy);

Moreover you can use a ctor without arguments directly:
NetOffice.VisioApi.Application application = new NetOffice.VisioApi.Application();

Now, NetOffice want fetch the type and create the instance for you.


*Sebastian
Sep 1, 2015 at 2:32 PM
Edited Sep 1, 2015 at 2:33 PM
Thank you, now i am receiving:

Error 6 Interop type 'NetOffice.VisioApi.Application' cannot be embedded. Use the applicable interface instead.

Ok, I do not see an interface.... this is crazy. Stupid day I guess. I am missing the obvious i'm sure.

I'll try setting Embed Interop Types under properties of the dlls to false and see if that works.
Coordinator
Sep 1, 2015 at 2:34 PM
hey,

please go to the reference option set "embed interop types" to false.(for each NO assembly)

*Sebastian
Sep 1, 2015 at 2:49 PM
Just did and thank you very much! Don't know how I missed that, but it dawned on me after I typed that reply (see my edits).

That was just pure brain block on not using the Netoffice instead of Microsoft. Tested in one service, added it another service late and night and automatically typed Microsoft. etc.

Sheesh. THANK YOU
Coordinator
Sep 1, 2015 at 3:11 PM
i know that feel bro'

good luck and bye!
*Sebastian
Oct 19, 2015 at 1:32 PM
Edited Oct 19, 2015 at 1:55 PM
This is now working on all machines except one - a windows server 2012 machine (the only windows server 2012). Is there something different required for permissions, configuration? Here is what we are doing on all machines (which works) except the 2012:
For enabling COM +  from applications:

1.  Run DCOMCNFG and Navigate to:
a.  Component Services
b.  Computers
c.  My Computer
d.  DCOM Config
e.  Microsoft Visio 2003-2010 Drawing
f.  Right click on Microsft Visio 2003-2010 Drawing and select Properties
g.  Click on the Identity tab:
i.  Select This user.
ii. Enter a valid user and password (recommend same user/password used for MDS installation)
iii.    Click Apply
*NOTE*  When the password changes or expired, it will need to be updated here

2.  Open Windows Services (services.msc) and Navigate to:
a.  COM+ Event System
i.  Double click to open properties and navigate to the Log On tab.  Set:
ii. Select This account:
iii.    Enter Local Service (or browse to it using the Browse button)
iv. Clear out the password fields
v.  Click Apply
vi. Click OK when the restart notifications appear.
b.  COM+ System Application
i.  Double click to open properties and navigate to the Log On tab.  Set:
ii. Select Local System account
iii.    Ensure Allow service to interact with desktop is checked!
iv. Click Apply
v.  Click OK when the restart notifications appear.
3.  Open Visio
a.  Create a blank drawing
b.  Navigate to File, Options, Trust Center
c.  Click Trust Center Settings
i.  Select Trusted Locations
1.  Add new location button
2.  Enter the path to the accdraw files our service is configured to use
3.  Click OK to save
ii. Select Trusted Documents
1.  Ensure Allow documents on a network to be trusted is checked
iii.    Select File Block Settings 
1.  Remove all checks (deselect) Open and Save for each File Type under File Block settings 
*Note* This is counter-intuitive, make sure all are NOT selected*
2.  Click OK
Nov 15, 2016 at 6:49 AM
I have the same issue on Win 2012 and needs to change the setting in DCOMCNFG for it to work.
Is there any other way without changing DCOM setting?
Thanks.