codesmithtools / Templates

CodeSmith Generator Templates
http://www.codesmithtools.com/product/generator
54 stars 35 forks source link

CAS Policy Issue - Nettiers #720

Closed OpenSpacesAndPlaces closed 3 years ago

OpenSpacesAndPlaces commented 3 years ago

.csp(0,0) This method implicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information. Stack Trace: at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence securityEvidence) at Microsoft.JScript.JSCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames) at System.CodeDom.Compiler.CodeCompiler.FromDomBatch(CompilerParameters options, CodeCompileUnit[] ea) at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] ea) at System.Xml.Xsl.XsltOld.Compiler.CompileAssembly(ScriptingLanguage lang, Hashtable typeDecls, String nsName, Evidence evidence) at System.Xml.Xsl.XsltOld.Compiler.CompileScript(Evidence evidence) at System.Xml.Xsl.XsltOld.Compiler.Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) at System.Xml.Xsl.XslTransform.Compile(XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence) at _CodeSmith.NetTiers_cst.Go() in C:\GitRepos_netTiers-2.3.2\NetTiers.cst:line 1846 at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control) in C:\GitRepos_netTiers-2.3.2\NetTiers.cst:line 5063 at CodeSmith.Engine.Control.RenderChildren(TextWriter writer) at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer) at CodeSmith.Engine.CodeTemplate.RenderToString() at CodeSmith.Engine.CodeTemplate.RenderToFile(OutputFile outputFile, Boolean overwrite) at CodeSmith.Engine.ProjectCodeGenerator.GenerateCode(CodeSmithProject project)


Any idea what the resolution to this is? I tried adding "NetFx40_LegacySecurityPolicy " to the visual studio config, but it didn't help (just made it fail silently).

niemyjski commented 3 years ago

Thanks for reaching out. To resolve this issue you need to delete the templates, unblock the zip file and reextract the templates.

  1. Save the file onto your computer.
  2. Click Start, click My Computer, and navigate to the file that you saved.
  3. Right-click the file that you saved, and then click Properties.
  4. Click Unblock near the bottom of the dialog box.
OpenSpacesAndPlaces commented 3 years ago

I'm not sure I follow - what zip file and what is being unblocked? Literally just running a csp against the Nettiers cst with cs.exe

This seems to be recent issue - I'm guessing relating to something Microsoft did.

Been using Codesmith since 2012 and this an error I have not seen before.

@niemyjski

OpenSpacesAndPlaces commented 3 years ago

Nevermind - I see the problem - there's a block on the "scriptsql.xsl" file itself.

niemyjski commented 3 years ago

This error is a result from downloading templates from a website and Windows OS putting restrictions on extracted files. You'll need to delete the files extracted from a zip and unblock the zip and reextract them.

OpenSpacesAndPlaces commented 3 years ago

This fixed it: https://www.404techsupport.com/2016/06/24/unblock-files-powershell/

dir -Path "dirwherenettierslives" -Recurse | Unblock-File