Showing posts with label config. Show all posts
Showing posts with label config. Show all posts

Monday, January 14, 2013

Load .Net 4 Dll From Powershell

Powershell 2 by default uses .Net 2. This means that if you try to load a DLL made in .Net 4 from Powershell 2, you will get the the following error.

Add-Type : Could not load file or assembly '' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

This can be solved as follows:


  1. Locate the Powershell executable. This is either under C:\Windows\System32\WindowsPowershell\v1.0 in a 32-bit machine, or C:\windows\SysSOS64\WindowsPowerShell\v1.0 in a 64-bit machine.
  2. Check if a file called PowerShell.exe.config exists. If it does, edit it. If it does not, create it.
  3. Make sure this config file contains these lines.

<?xml version="1.0"?> 
<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
        <supportedRuntime version="v4.0.30319"/> 
        <supportedRuntime version="v2.0.50727"/> 
    </startup> 
</configuration>



Monday, August 20, 2012

Reasons to remove debug=true from web.config

Before deploying your web application, always ensure that debug=true is removed. These are some side effects of leaving this in, which might be useful while debugging, but which be a huge cost once you go live.


  • Files needed for your application are not created immediately.
  • Temporary files are created
  • There is no timeout in debugging
  • Batch compilation is disabled
  • System.Diagnostics.DebuggableAttribute gets added to all generated code which causes performance degradation.
  • Scripts and images are not cached