Bookmark and Share
Showing posts with label VS2010. Show all posts
Showing posts with label VS2010. Show all posts

Sunday, November 07, 2010

Howto enable performance profiling on IIS and VS2008

If you are using VS2008/2010 and you need to profile your code you can have the warning:

The profiling environment for ConsoleApplication2 is not set up correctly. Use vsperfclrenv.cmd to setup environment variables. Continue anyway?

The solution is to execute the vsperfclrenv.cmd located under:

C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools>vsperfclrenv.cmd /globalsampleon

using the globalsampleon option.

Thursday, August 26, 2010

How to Add JQuery Intellisense to JS libraries in VS2010

If you work with JQuery and VS2010 you will find usefull enabling intellisense support for JQuery, for example:

or 





You can have the JQuery Intellisense following this steps:


  1. Download from the JQuery site the file jquery-1.4.1-vsdoc.js, search for the Visual Studio link near the release link
  2. Add the file to your project
  3. Change your js file and add to the top of the file:

Hope it helps!

Thursday, May 20, 2010

Migrating external assemblies used in RDLC from VS2005 to VS2010

If you are using ReportViewer and RDLC reports in visual studio 2005 you may use externals assemblies for additional rules and formulas, in order to enable external assemblies you need to call the AddTrustedCodeModuleInCurrentAppDomain function.
rv.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

Porting this code  to VS2010 without changes will generate the exception:

Exception of type 'System.Web.HttpException' was thrown.
Exception of type 'System.Web.HttpUnhandledException' was thrown.
Report execution in the current AppDomain requires Code Access Security policy,
which is off by default in .NET 4.0 and later.
Enable legacy CAS policy or execute the report in the sandbox AppDomain.

With the exception detail:

Exception of type 'System.Web.HttpException' was thrown.
Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.Util.AspCompatApplicationStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Exception of type 'System.Web.HttpException' was thrown.
Exception of type 'System.Web.HttpUnhandledException' was thrown.
Report execution in the current AppDomain requires Code Access Security policy, which is off by default in .NET 4.0 and later. Enable legacy CAS policy or execute the report in the sandbox AppDomain.
at Microsoft.Reporting.WebForms.LocalReport.ReportRuntimeSetupHandler.AddTrustedCodeModuleInCurrentAppDomain(String assemblyName)
at Microsoft.Reporting.WebForms.LocalReport.AddTrustedCodeModuleInCurrentAppDomain(String assemblyName)
at Web.Report.OnInit(EventArgs e) in C:\inetpub\wwwroot\Web\Report.aspx.cs:line 500
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


The solution is to use the new AddFullTrustModuleInSandboxAppDomain function, using the SetBasePermissionsForSandboxAppDomain function, here is an example:



using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
//...
//... 
PermissionSet permissions = new PermissionSet(PermissionState.None);
permissions.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
permissions.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
rv.LocalReport.SetBasePermissionsForSandboxAppDomain(permissions);
Assembly asm = Assembly.Load("MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
AssemblyName asm_name = asm.GetName();
rv.LocalReport.AddFullTrustModuleInSandboxAppDomain(new StrongName(new StrongNamePublicKeyBlob(asm_name.GetPublicKeyToken()), asm_name.Name, asm_name.Version));

Hope it helps!, and happy coding!