CAS give exception while Assembly.LoadFile RRS feed

  • Question


    Hello All,

    _assembly = Assembly.LoadFile("D:\\Calc.dll");

    The above API throw below exception.

    “An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.”

    Problem got resolved after adding below setting in .config file of my exe.


          <loadFromRemoteSources enabled="true"/>


    Please refer below link for the details:


    Based on the exception found I came to know the reason is CAS (Code Access Security) in .net.

    I would appreciate if someone has answers to following questions:

    1.        We are not sure about how to recreate the scenario. Does anyone have idea?
    2.        Will it break/violate any security standards of my exe if I apply above solution?



    Thursday, March 17, 2016 1:22 PM