tags:

views:

247

answers:

1

Hello friends, I am trying to migrate my MOSS 2007 Webparts to Sharepoint 2010 environment.My environment is Windows Server 2008 64Bit,Visual Studio 2008,Sharepoint 2010. On adding the webparts to a Sharepoint 2010 Site behind the scene it is accesing the configuration file of log4net,While accesing this file its giving an error like "SecurityException was unhandled by user code".

it is getting while running this line of code :

FileInfo fi = new FileInfo(log4netConfigFilePath);

Exact Error from Exception Type:

"Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

This is the Stack Trace:

at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.IO.FileInfo..ctor(String fileName) at ProjectWorld.Logging.LogManager.Configure() at ProjectWorld.Logging.LogManager.EnsureConfiguration() at ProjectWorld.Logging.LogManager.GetLogger(WebPart webPart) at ProjectWorld.WebParts.PRSWebParts.QBWebPart..ctor() at T_c39ca68b_5b0a_4d36_b052_e470116a6771.CreateInstance() at System.Web.HttpRuntime.FastCreatePublicInstance(Type type) at System.Web.UI.WebControls.WebParts.WebPartManager.ImportWebPart(XmlReader reader, String& errorMessage)

I am running this code under Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges,then also i am getting this error.

PLease help me to solve this error. BEcause of this i cant the add webpart to the page.Thanks

A: 

Set the web.config of your application to run with full trust. ()

It would be better to change the code and assign the privilege (see Code Access Security documentation) and deploy a custom trust file along with your application.

Roel Hans Bethlehem
hi the applicaiton is already running under full trust level
Abin Jaik Antony