Welcome to the CodeSmith Community!

RE: 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
  • Hi there,

     

    I have just installed a fresh copy of Codesmith 5.3.4 R12823 and have a project within a Visual Studio 2010 solution which contains a stock standard 2.3.1 NetTiers.csp template.  This codesmith project and associated template generate fine from outside VS2010 however when "Generate Outputs" is selected from the context menu of the .csp file from within VS it gets halfway through generating files and then spits out the following error:

     

    ERROR: W:\XXX\Code\XXX.DAL.NetTiers\2.3.1\NetTiers - XXX.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.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromDom(CompilerParameters options, CodeCompileUnit[] compilationUnits)

       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 System.Xml.Xsl.XslTransform.Load(String url, XmlResolver resolver)

       at System.Xml.Xsl.XslTransform.Load(String url)

       at _CodeSmith.NetTiers_VirtuosoData_cst.Go() in w:\XXX\Code\XXX.DAL.NetTiers\2.3.1\NetTiers - XXX.cst:line 1841

       at _CodeSmith.NetTiers_XXX_cst.__RenderMethod1(TextWriter writer, Control control) in w:\XXX\Code\XXX.DAL.NetTiers\2.3.1\NetTiers - XXX.cst:line 5017

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

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

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

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

       at CodeSmith.Engine.CodeTemplate.RenderToFile(OutputFile outputFile, Boolean overwrite)

       at CodeSmith.Engine.CodeTemplate.RenderToFile(String path, Boolean overwrite)

       at CodeSmith.Engine.ProjectCodeGenerator.GenerateCode(CodeSmithProject csp)

     

     

    The last successful file generated according to the outputs was Procedures.xml (in the SQLClient project) if that helps.

     

    I did some research and found that <NetFx40_LegacySecurityPolicy enabled="true" /> can be added to the <runtime> section of the devenv.exe.config file which allows it to generate from within VS2010.  This causes other issues when it comes to trying to compile the solution which contains a WPF UI and also causes design time issues with third-party UI controls.  

     

    Is there another fix for this?

     

    Thanks,

    Jesse

  • Hello,

    First, I would never generating .netTiers from within Visual Studio as the .netTiers 2.3 templates were not designed to be generated this way, the next version will be.

    I've never come across this error before but it looks like the templates are on a network drive and or the templates are marked as blocked (support.microsoft.com/.../902225). Do you have a antivirus installed and is your pc completely up-to-date?

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

  • Hi Blake,

    It is a brand new machine (a few days old) with brand new Win 7 Ultimate SP1 and only known software installed so far.  No antivirus installed yet but certain there are no viruses.  Don't be put off by the W:\ drive, it's just a local harddisk partition i call my 'Workspace'.  

    I'm not sure what you refer  to specifically when you say NetTiers was not designed to be generated this from within VS.  What difference should it make?    Also, not sure if that you put up is right, it doesn't appear to have anything to do with the topic.

    When you say the next version of NetTiers will be compatible with VS will that require a new version of Codesmith also?  i just upgraded my Codesmith 2 days ago hoping this feature would be available.  It is not a biggy, i can still generate from outside ok, however I would appreciate it if there was a fix.

    Thanks,

    Jesse

  • Hello,

    Do you have any other Visual Studio add-in's installed? Do you have another computer you can test this on to see if it happens on that machine as well? Would you be willing to enter a go-to-meeting session so I could take a closer look? I've been using the Visual Studio integration daily and have never or saw any reports of this issue.

    It makes a big difference because the .netTiers templates generates files into different projects when a csp only supports generating into the project it is apart of. The templates call RenderToFile, which tells the CSP to check the files out and add the files to the VS Project. For this case it is the recommended approach not to generate inside of Visual Studio the .netTiers templates due to multiple projects.  I'm not saying it's not possible to generate within visual studio the .netTiers templates, I'm just saying it wasn't designed that way...

    Then next version of .netTiers will work with 5.x, and will work much like the PLINQO templates where each generated project would have a csp..

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

  • Hi Blake,

    Yeah I have tried it on another Win 7 machine and same deal.  Welcome to take a look, just need to arrange a time.  In Australia here though.  

    Jesse

  • Hello,

    Sure, we could set up a meeting for the afternoon here/morning there. Please just contact support@codesmithtools.com and we will set up a time.

    Thanks

    -Blake Niemyjski

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

  • Hello,

    What version of .netTiers and CodeSmith Generator are you running? Is this a runtime or generation exception for .netTiers? Can you please post the full stack trace of this error.

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

  • It is a generation exception for me.  Using .netTiers 2.3.1 with CodeSmith 6.0.1 R14056. Here's the 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 d:\Downloads\nettiers-2.3.1\NetTiers.cst:line 1841

      at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control) in d:\Downloads\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,

    How are you guys generating .netTiers inside of Visual Studio? I tried generating it from within Template Explorer, as part of a CSP Output, and from the Template Editor and couldn't reproduce this behavior. This error happens when the xslt tries to load and transform the generated Xml file (for the stored procedures) using the Microsoft Xml Namespaces...

    As a work around, I'd strongly recommend not generating .netTiers from within Visual Studio as that is not how .netTiers was meant to be generated as it generates an entire VS solution with many Visual Studio Projects.

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

    Suggested by
  • I'm not actually doing anything inside of Visual Studio.  I double-click on the netTiers template, I don't edit anything other than my data source, and the error happens.

    I was able to suppress the error, by putting this tag in the CodeSmith config files in C:\Program Files (x86)\CodeSmith\v6.0:

    <configuration>

     <runtime>

        <NetFx40_LegacySecurityPolicy enabled="true"/>

     </runtime>

    </configuration>

    Suggested by
  • Hello,

    I'd really like to be able to reproduce this issue and get it fixed in the templates. Is there any chance you could attach a CodeSmith Generator Project File of your .netTiers templates that you are generating. I tried this scenario you described above and can't reproduce on Windows 7 X64.

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

  • Here you go.

     

    CK

     

  • Hello,

    I'm not seeing any file attached. Could you please log in to attach the file.

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

  • I'm not sure where to attach the file?  I thought the email would do it.

Page 1 of 2 (27 items) 12