Hi,
I got the security exception in underlined code:
string
sAppProgID = "Excel.Application"; object oExcel = null; try{
oExcel = Marshal.GetActiveObject(sAppProgID);
}
catch(Exception ex){
MessageBox.Show(ex.StackTrace);
try{
Type tExcelObj = Type.GetTypeFromProgID(sAppProgID);
oExcel = Activator.CreateInstance(tExcelObj);
}
catch(Exception ex2){
MessageBox.Show(ex2.StackTrace);
return;}
}
Why is it happened and how can I solve it
Thank's
Alexei

SecurityException
dwl
Hi,
I know. I give to it but get the error that it can't find the object.
Thank's
Alexei
Dee_dotnet_79
Hi,
The type of oExcel object is Object and I can't take the exist object of Excel or create new object of Excel. It tells me security exception. If I add it to security permissions I get error with no reference to object Excel.Application.
Thank's
Alexei
markse
Hi,
Excel.Application
Thank's
Alexei
zariusan
Rather than just displaying the StackTrace, try putting more of the SecurityException in your message box with MessageBox.Show (ex). I don't know all the properties SecurityException.ToString() includes in the message but it should provide more details on the security error that occurred. For even more data you could either show all the SecurityException properties or more quickly just examine ex with the debugger.
FannwongCindy
Rockman Eugene
Hi,
I am getting error System.Security.Permissions.SecurityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral
How to solve it
Thank's
Alexei
dataMonkey
I assume that Excel is running Also what is the type of your oExcel
Mansoor Shiraz
What object exactly are you referring to