Welcome to the CodeSmith Community!

Run NTiers get me a System.NotSupportedException CAS Policy. What can I do to circumvent this problem????

Support Forums

Feel free to ask any questions about CodeSmith here.

Run NTiers get me a System.NotSupportedException CAS Policy. What can I do to circumvent this problem????

Answered (Verified) This question is answered

When I Run NTiers, I get System.NotSupportedException: This method implicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons a System.NotSupportedException CAS Policy.  What can I do to circumvent this problem????

The fix they give in msdn is to set a tag in app.config file and I cannot do that in .nettiers template.

 

Can anyone help me???

 

Thanks!

Manuel Chapa Software Engineer
  • Post Points: 35
All Replies
  • Hello,

    You can send the file to support@codesmithtools.com as well. Or if you log into this forum and select reply with  "use rich formatting" you can attach a file.

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • Statements_NetTiers_2_3_1.txt

    I am also having the same error on Win 7 X64 machine using CodeSmith that I just downloaded today 6.X and using NetTiers template version 2.3.1 downloaded from Google. A bit of information that might be helpful is that everything was working fine while using the template bundled with the CodeSmith download but after updating the template it starts to fail.

    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 go.microsoft.com/fwlink 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:\NetTiers_2_3_1\NetTiers.cst:line 1841

    at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control) in c:\NetTiers_2_3_1\NetTiers.cst:line 5017

    at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)

    at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)

    at CodeSmith.Engine.CodeTemplate.RenderToString()

    at CodeSmith.Engine.Remoting.TemplateSession.#2Yc()

    at System.Threading.Tasks.Task`1.InvokeFuture(Object futureAsObj)

    at System.Threading.Tasks.Task.Execute()

  • Hello,

    Thanks for posting this. I haven't been able to reproduce this issue following your steps. If you move the .netTiers templates that you downloaded to a user directory like (my documents) do you get this error? What are your UAC Settings set to?

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • Hello,

    I moved the NetTiers_2_3_1 to C:\Users\Rob\Documents\CodeSmith\Samples\v6.0\Templates\Frameworks\NetTiers_2_3_1 and tried again.  Same error.  I ran the CodeGenerator as Admin, same error.  I retried the v6.0 NetTiers that came with CodeGenerator and it still works.  Only the 2.3.1 template.

    My UAC settings are:

    "Notify me only when programs try to make changes to my computer (do not dim my desktop)"

    I appreciate your help...

    Rob Classen

  • Hello,

    Thanks, If you right click->properties the netTiers zip that you downloaded, is it marked as blocked?

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • Why, yes it is.  If I "unblock" it and try again, it generates without errors.  Everything is right with the world again!

    Thanks

  • Hello,

    Thanks for that information. We'll take a look :)

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • This has been fixed in Generator 6.0.2

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

  • I just downloaded the latest Generator 6.0.2 to try to get rid of my error but it didn't help.  Please advise.

    This is the error I got right after it generated the Procedures.xml file

    NetTiers.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 go.microsoft.com/fwlink for more information.

    Full Error:

    Error: NetTiers.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 go.microsoft.com/fwlink 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 g:\My Documents\_websites\Starter Solution\nettiers-2.3.1\NetTiers.cst:line 1841

      at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control) in g:\My Documents\_websites\Starter Solution\nettiers-2.3.1\NetTiers.cst:line 5017

      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 csp)

    Unable to render output NetTiers.txt, skipping...

    Done rendering outputs: 0 succeeded, 1 failed, 0 skipped (4914ms).

  • I forgot to include that I am running on Windows 7 Professional SP1 x64 bit and using Visual Studio 2010.  But I can't "generate" using just code smith or inside of Visual Studio 2010.   Neither one will generate without that error.  Please advise.  I need to generate.

  • I was finally able to over come this by editing the file "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config and adding <NetFx40_LegacySecurityPolicy enabled="true"/> to the <runtime> section of that config.  I also noticed that after that it was best only to "generate" inside of Visual Studio 2010.  If I tried to generate just using code smith, it would error out again and I wouldn't be able to generate again until I closed my Visual Studio and used VS only to generate.

  • Hello,

    You should be seeing an error message as follows in Generator 6.0.2:

     

    One or more template resources may have been downloaded from the Web. If a archive or assembly has been downloaded from the Web, it is 
    flagged by Windows as being a Web file, even if it resides on the local computer. This has prevented you from successfully generating. Please 
    change this designation by changing the file properties and regenerate. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information.

    I'd highly recommend generating .netTiers outside of Visual Studio as that is the way the templates were initially designed. This error is a result of downloading the templates from the web. If you right click a zip and mark it as unblocked this error will go away.

     

    Blake Niemyjski
    CodeSmith Tools, LLC. Software Development Engineer
    Blog: http://windowscoding.com/blogs/blake/
    .NetTiers team | Visit http://www.nettiers.net

Page 2 of 2 (27 items) 12