locked
POS for .NET and Framework 4

    Question

  • Hi! I try to use POS FOR .NET and Framework 4 in my application. But when i try to create PosExplorer (for example) i get next exception:

    This method explicitly 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.

    How to decide this problem? Or POS for .NET do not compatible with Framework 4?

    • Edited by Valeck Thursday, May 06, 2010 8:56 PM
    Thursday, May 06, 2010 3:42 PM

Answers

  • I have found the following decision: it is necessary to insert

    <configuration>
       <runtime>
          <NetFx40_LegacySecurityPolicy enabled="true"/>
       </runtime>
    </configuration>
    in
    devenv.exe.config

    • Marked as answer by YortEditor Friday, May 07, 2010 9:38 PM
    Friday, May 07, 2010 9:18 AM

All replies

  • I'm having the same problem
    Thursday, May 06, 2010 6:57 PM
  • Hi,

    Interesting. Microsoft dropped support for "Code Access Security" in .Net 4 (basically because they decided it wasn't useful 99% of the time). CAS now only applies with .Net 4 under certain hosting situations, such as when the CLR is hosted inside Sql Server etc. but not standard Win32 processes (i.e your application).

    While I knew about them dropping support, I didn't realise it was going to cause this problem. In fact, I had heard that it should all work transparently and no issues should arise... clearly that is not the case.

    The link you posted does suggest a workaround... place the following in your applications .config file;

    <configuration>
       <runtime>
          <NetFx40_LegacySecurityPolicy enabled="true"/>
       </runtime>
    </configuration>

    Have you tried that ? It should work. Of course, if you want to run without a configuration file (which I do in some of my apps) or if you have some other reason to want to avoid modifying the existing config file it looks like you're stuck without an update to the Pos .Net library itself.

    Hopefully someone from the Pos .Net team will see this an expedite a new release that is .Net 4 compatible.

    Friday, May 07, 2010 4:48 AM
    Answerer
  • Hi! Thanks for the answer. I tried this decision, but it has not solved all problem.
    We use DevExpress 10.1 and Visual Studio 2010.
    And when i try to open designer of model, i get this exception.
    It is not error of runtime, it is error of design time.
    Friday, May 07, 2010 6:49 AM
  • Hi,

    You said the error occurred creating PosExplorer... I didn't realise PosExplorer had a designer or component you could place on a designer. Normally PosExplorer is created in code using the new keyword.

    How are you getting PosExplorer on the designer ? Which designer is it ?

    Friday, May 07, 2010 7:38 AM
    Answerer
  • I have initially simplified a question. It is my error. Excuse. In case of creation PosExplorer in a code your decision works. Let's make a fresh start. There is a class in which is used PosExplorer. It is created in a code. And this class is used for construction of model DevExpress in the designer. And here at start of this designer there is an exception.
    Friday, May 07, 2010 7:58 AM
  • Interesting. So do you get the same error when you run the application if you DON'T have the modification made in the config file ? In theory there shouldn't be any difference between creating the PosExplorer instance at design time or at runtime.

    What does the stack trace of the error show... is the error coming from a Pos .Net assembly or a DevExpress one ?

     

    Friday, May 07, 2010 8:04 AM
    Answerer
  • No, the project links and works. The problem only at start of the designer. Here the error text:

    Exception occurs while creating
    DevPark.WinterQueen.Module.Win.MainWindowController
    Unable to create an instance of the
    "DevPark.WinterQueen.Module.Win.MainWindowController" type.
    Reason: "The type initializer for
    'Microsoft.PointOfService.Management.Explorer' threw an exception.",
    inner exception: "This method explicitly 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.",
    inner exception stack trace: "   at
    System.Security.SecurityManager.ResolvePolicy(Evidence evidence)
      at Microsoft.PointOfService.Management.Explorer.ScanForSOAssemblies()
      at Microsoft.PointOfService.Management.Explorer.Refresh()
      at Microsoft.PointOfService.Management.Explorer..ctor()
      at Microsoft.PointOfService.Management.Explorer..cctor()"
    end inner exception stack trace

    Friday, May 07, 2010 8:38 AM
  • So do you get the same error when you run the application if you DON'T have the modification made in the config file ? - Excuse. Yes, i`m get the some error
    Friday, May 07, 2010 9:07 AM
  • I have found the following decision: it is necessary to insert

    <configuration>
       <runtime>
          <NetFx40_LegacySecurityPolicy enabled="true"/>
       </runtime>
    </configuration>
    in
    devenv.exe.config

    • Marked as answer by YortEditor Friday, May 07, 2010 9:38 PM
    Friday, May 07, 2010 9:18 AM
  • Glad you found the solution ! Shame it's neccessary at all :(

     

    Friday, May 07, 2010 9:38 PM
    Answerer
  • Hi! It has appeared, what not all so is good. Now, at project build, there is an error which was not earlier. The most interesting that when I wrote last message, such error was not...

    Unknown build error, 'The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.'

    So it is possible to consider a question opened...

    Tuesday, May 11, 2010 9:22 AM
  • Hi! It has appeared, what not all so is good. Now, at project build, there is an error which was not earlier. The most interesting that when I wrote last message, such error was not...

    Unknown build error, 'The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.'

    So it is possible to consider a question opened...

    found any solution to this, all the projects that was using pos.net begun to have that error.
    Wednesday, June 02, 2010 9:50 AM
  • Hi! It has appeared, what not all so is good. Now, at project build, there is an error which was not earlier. The most interesting that when I wrote last message, such error was not...

    Unknown build error, 'The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.'

    So it is possible to consider a question opened...


    Hi everone,

    Someone found the solution?

    I've the problem with all resources file I put in the project.

    Monday, July 19, 2010 5:32 PM
  • Hello 

    I'm having the same problem "Unknown build error, 'The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag."

    It seem to only manifest itself in my Test Projects. 

    I'm working on a Pos for .Net 1.12 solution.. anyone having similar issues? 

    Thanks

    Tuesday, October 19, 2010 1:11 PM
  • Microsoft should get real. I recenly had to revert to .netframework 2.0 from .netframework 4.0 because of POS.Net incompatibility. It is a shame that while they upgrade platforms they fail to bridge a transition link between old and new systems. Is this because of absence of Bill as active partner? I am a frustrated developer been on microsoft platform for 15 years. I am considering leaving Microsoft for JAVA platform which has more consistancy, smooth and even upgrade policy.

    I do not normally write on forums but just think that microsoft should listen to consumers. Considering this topic, I will advise you to revert to .framework 2.0 for safety of a successful project completion. You do not want your application to crash during or after launch. I had bad experience of fiddling with configuration file in order to use POS.net on .netframwork 4.0.

    Wednesday, May 02, 2012 3:21 AM
  • Hi Sidibeh,

    Please take a look over this link.  We faced same set of issues and all these tricks worked.

    http://blog.lavablast.com/post/2011/06/06/Using-Microsoft-POS-for-NET-in-2011.aspx

    Good luck!

    Tuesday, May 29, 2012 9:06 PM
  • Hello Valeck,

    I am having same problem  while creating a new  posexplorer  instance. But adding the code above  in the web.config file  is not solving the issue.Can u pls help me out in this regard. I am using POS for .NET v1.12 for integrating my application with a barcode scanner and its an web application. thanks in advance.

    Regards,

    Hrid

    Wednesday, August 29, 2012 10:12 AM
  • I am having a pos based project in which i need to have hardware integration and also need dynamic operation.

    but Dynamic operations can only be performed in homogenous AppDomain error is coming

    because of

    <NetFx40_LegacySecurityPolicy enabled="true" />

    this.

    but i must need that code for hardware integration in my project.

    i am having 6 project in my solution,

    i need <NetFx40_LegacySecurityPolicy enabled="true" /> and dynamic operation in my project although both are in different project.

    please Provide the solution

    Monday, September 10, 2012 7:42 AM
  • Same problem as Nick Nishu, please if someone has a solution or workaround i am very interested.

    EF

    Thursday, October 04, 2012 11:55 PM
  • Thanx Valeck,, The solution was really helpfull.. :)

    Avatar of Valeck thanx



    pankaj nagarsekar

    Tuesday, December 18, 2012 5:52 AM
  • POS for .NET 1.12 requires .NET 2.0 runtime to be installed. There is a new POS for .NET 1.14 currently in CTP that will support .NET Framework 4.0.

    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WE8S, Pro Guide to WES 7, Pro Guide to POS for .NET

    Saturday, February 01, 2014 6:53 PM
    Answerer
  • Is there any way to get access to the 1.14 version now? We're in desperate need as well..


    --

    Sunday, February 16, 2014 6:41 AM
  • Hi Mitchell,

    The POS for .NET v. 1.14 CTP is available for the public and is available here.  This will allow you to begin working with it and filing issues or asking questions on our forum before the final product is released later this spring.

    Thanks!

    Christine Ahonen

    Microsoft Program Manager - POS for .NET Team

    Monday, February 17, 2014 6:18 PM
  • Great, thanks! I'll check it out tomorrow on the dev machines.

    Unfortunately the link to the forum on that page gives an error.


    --

    Tuesday, February 18, 2014 1:00 AM
  • Mitchel,

    The link auto registers you in the program.  You may have to close the browser and reenter the page. If you continue having access issues please let me know.

    Thanks!

    Christine Ahonen

    Microsoft Program Manager - POS for .NET Team

    Tuesday, February 18, 2014 9:12 PM