MS Project handling with php

0

I've created a small C# console program that handles and exports some stuff from MSProject. After I have installed Microsoft Server 2008, and tested my program from console. Then as a final step I've installed apache&php, but I couldn't force my program to work by php calls. I think it is permission errors, but I have added "Everyone" group to all exes(MSProject.exe, myconsoleapp.exe) also the msprojectfile.mpp with full controll(I know I shouldn't do that, but first I want it to work).

Some more things that i tried: I have tested if the input paramters from php are wrong. I have tested if other small program(exe, batch etc.) running. Tested severl version from local console. I have tried to give sleeps, since console etc...

Here are some codes:

php:

exec("C:\Apache24\htdocs\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe C:/Apache24/htdocs/mympp.mpp 1 data1 data2 data3 data4 data5 data6 data7 data8 data9 data10 data11 2>&1", $output, $answer);
echo "answer = " . $answer;
var_dump($output)

ConsoleApp:

static void Main(string[] args)
{
    for (int i = 0; i < 13; i++)
    {
        //Writing out some debug info
        Console.WriteLine(i.ToString() + ":" + args[i]);
    }

    //<Setup>
        Microsoft.Office.Interop.MSProject.ApplicationClass msProjectApp;
        Project project;
        Thread.Sleep(1000);
        Init(args, out msProjectApp, out project); //This Includes Leveling Reset
        return;
    //</Setup>
}

private static void Init(string[] args, out Microsoft.Office.Interop.MSProject.ApplicationClass msProjectApp, out Project project)
{
    msProjectApp = new Microsoft.Office.Interop.MSProject.ApplicationClass();
    Thread.Sleep(2000);
    //msProjectApp.AppMaximize(); //Maybe Delete

    //Where args[0] is the msprojectfile.mss file location
    LoadFromMPPFile(args[0], msProjectApp, out project);
    Thread.Sleep(2000);
    project.LevelClearDates();
}

private static void LoadFromMPPFile(string location,Microsoft.Office.Interop.MSProject.ApplicationClass msProjectApp,out Project project)
{
    object missingValue = System.Reflection.Missing.Value;
    //Dies at the next row
    msProjectApp.FileOpenEx(location,
    missingValue, missingValue, missingValue, missingValue,
    missingValue, missingValue, missingValue, missingValue,
    missingValue, missingValue, PjPoolOpen.pjPoolReadOnly,
    missingValue, missingValue, missingValue, missingValue,
    missingValue);
    Thread.Sleep(1000);
    project = msProjectApp.ActiveProject;
}

With this message from php:

answer = -532459699 array(20) { [0]=> string(35) "0:data1" [1]=> string(3) "1:data2" [2]=> string(6) "2:data3" [3]=> string(4) "3:data4" [4]=> string(4) "4:data5" [5]=> string(6) "5:data6" [6]=> string(4) "6:data7" [7]=> string(4) "7:data8" [8]=> string(3) "8:data9" [9]=> string(12) "9:data10" [10]=> string(35) "10:data11" [11]=> string(4) "11:data12" [12]=> string(17) "12:data13" [13]=> string(0) ""

Important part is here:

[14]=> string(166) "Unhandled Exception: System.Runtime.InteropServices.COMException (0x80010001): Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))" [15]=> string(149) " at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)" [16]=> string(393) " at Microsoft.Office.Interop.MSProject.ApplicationClass.FileOpenEx(Object Name, Object ReadOnly, Object Merge, Object TaskInformation, Object Table, Object Sheet, Object NoAuto, Object UserID, Object DatabasePassWord, Object FormatID, Object Map, PjPoolOpen openPool, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object XMLName, Object DoNotLoadFromEnterprise)" [17]=> string(249) " at ....Program.LoadFromMPPFile(String location, ApplicationClass msProjectApp, Project& project) in ..\ConsoleApplication1\ConsoleApplication1\Program.cs:line 194" [18]=> string(237) " at ...Program.Init(String[] args, ApplicationClass& msProjectApp, Project& project) in ...\ConsoleApplication1\ConsoleApplication1\Program.cs:line 186" [19]=> string(187) "...

c#
php
file-permissions
ms-project
asked on Stack Overflow Feb 3, 2016 by Balázs Szántó • edited Feb 3, 2016 by Doug

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0