P
Pallavi
Hello Sir,
I am creating .mpp file using c#.net in asp.net, I am getting COM Execption
"Call was rejected by callee. (Exception from HRESULT: 0x80010001
(RPC_E_CALL_REJECTED)) ". after change in "DCOMCNFG".
MY Code gose as....
private double DateDiff(System.DateTime startDate, System.DateTime endDate)
{
double diff = 0;
System.TimeSpan TS = new System.TimeSpan(startDate.Ticks - endDate.Ticks);
diff = Convert.ToDouble(TS.TotalDays);
return diff;
}
private void KillMSProjectProcess()
{
try
{
Process[] procs;
procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.ProcessName == "WINPROJ")
{
try
{
proc.Kill();
}
catch
{
}
finally
{
proc.Dispose();
proc.Close();
}
}
}
}
catch { }
}
private void startMSProjectProcess()
{
try
{
Process[] procs;
procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.ProcessName == "WINPROJ")
{
try
{
proc.Start();
}
catch
{
}
finally
{
proc.Dispose();
//roc.Close();
proc.Close();
}
}
}
}
catch { }
}
Microsoft.Office.Interop.MSProject.ApplicationClass projectApp;
protected void Button1_Click(object sender, EventArgs e)
{
try
{
String strDateTime = Guid.NewGuid().ToString();
String strFileName = Server.MapPath("test_" + strDateTime + ".mpp");
KillMSProjectProcess();
projectApp =
new
Microsoft.Office.Interop.MSProject.ApplicationClass();
if (projectApp != null)
{
projectApp.Visible =
true;
projectApp.AppMaximize();
projectApp.FileNew(
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Microsoft.Office.Interop.MSProject.Project project =
projectApp.ActiveProject;
Microsoft.Office.Interop.MSProject.Task task;
string t1, t2;
for (int i = 0; i < 10; i++)
{
task = project.Tasks.Add(
"Task" + i.ToString(), i + 1);
t1 =
"10/12/2005";
t2 =
"12/12/2005";
task.Duration = DateDiff(
Convert.ToDateTime(t2), Convert.ToDateTime(t1));
task.Start = t1;
task.Finish = t2;
task.Text1 =
"Task_TestTask" + i.ToString();
}
Object objT = true;
projectApp.FileSaveAs(strFileName,
Microsoft.Office.Interop.MSProject.PjFileFormat.pjMPP,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, "MSProject.mpp", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
projectApp.Quit(PjSaveType.pjDoNotSave);
projectApp =
null;
//projectApp.FileCloseAll(PjSaveType.pjDoNotSave);
}
}
catch (Exception Ex)
{
String strEx = Ex.Message;
}
}
and I have another doubt that is
"MSProject.ApplicationClass" in ASP.net is allows to create Multiple
Object instances at a time? Becoze the site will be used by many people may
try to create .mpp file at a time.
Please Help Me.
Thank you sir.
I am creating .mpp file using c#.net in asp.net, I am getting COM Execption
"Call was rejected by callee. (Exception from HRESULT: 0x80010001
(RPC_E_CALL_REJECTED)) ". after change in "DCOMCNFG".
MY Code gose as....
private double DateDiff(System.DateTime startDate, System.DateTime endDate)
{
double diff = 0;
System.TimeSpan TS = new System.TimeSpan(startDate.Ticks - endDate.Ticks);
diff = Convert.ToDouble(TS.TotalDays);
return diff;
}
private void KillMSProjectProcess()
{
try
{
Process[] procs;
procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.ProcessName == "WINPROJ")
{
try
{
proc.Kill();
}
catch
{
}
finally
{
proc.Dispose();
proc.Close();
}
}
}
}
catch { }
}
private void startMSProjectProcess()
{
try
{
Process[] procs;
procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.ProcessName == "WINPROJ")
{
try
{
proc.Start();
}
catch
{
}
finally
{
proc.Dispose();
//roc.Close();
proc.Close();
}
}
}
}
catch { }
}
Microsoft.Office.Interop.MSProject.ApplicationClass projectApp;
protected void Button1_Click(object sender, EventArgs e)
{
try
{
String strDateTime = Guid.NewGuid().ToString();
String strFileName = Server.MapPath("test_" + strDateTime + ".mpp");
KillMSProjectProcess();
projectApp =
new
Microsoft.Office.Interop.MSProject.ApplicationClass();
if (projectApp != null)
{
projectApp.Visible =
true;
projectApp.AppMaximize();
projectApp.FileNew(
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Microsoft.Office.Interop.MSProject.Project project =
projectApp.ActiveProject;
Microsoft.Office.Interop.MSProject.Task task;
string t1, t2;
for (int i = 0; i < 10; i++)
{
task = project.Tasks.Add(
"Task" + i.ToString(), i + 1);
t1 =
"10/12/2005";
t2 =
"12/12/2005";
task.Duration = DateDiff(
Convert.ToDateTime(t2), Convert.ToDateTime(t1));
task.Start = t1;
task.Finish = t2;
task.Text1 =
"Task_TestTask" + i.ToString();
}
Object objT = true;
projectApp.FileSaveAs(strFileName,
Microsoft.Office.Interop.MSProject.PjFileFormat.pjMPP,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, "MSProject.mpp", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
projectApp.Quit(PjSaveType.pjDoNotSave);
projectApp =
null;
//projectApp.FileCloseAll(PjSaveType.pjDoNotSave);
}
}
catch (Exception Ex)
{
String strEx = Ex.Message;
}
}
and I have another doubt that is
"MSProject.ApplicationClass" in ASP.net is allows to create Multiple
Object instances at a time? Becoze the site will be used by many people may
try to create .mpp file at a time.
Please Help Me.
Thank you sir.