4 Replies Latest reply on Jan 13, 2015 2:12 PM by David Hearn

    Could not load file or assembly 'OSIsoft.AF.Security.UI'....

    gortega

      Hi all,

      I am getting the following error at run time, this is a WCF project and it compiles just fine, any idea what I am doing wrong?

      Thanks,

      Gerardo

      Server Error in '/' Application.


      Could not load file or assembly 'OSIsoft.AF.Security.UI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

         Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

      Exception Details: System.BadImageFormatException: Could not load file or assembly 'OSIsoft.AF.Security.UI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

      Source Error:

      An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  


      Assembly Load Trace: The following information can be helpful to determine why the assembly 'OSIsoft.AF.Security.UI' could not be loaded.

      === Pre-bind state information === LOG: DisplayName = OSIsoft.AF.Security.UI (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: OSIsoft.AF.Security.UI | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/SAMS/Sams.AlarmAdministrationService/ LOG: Initial PrivatePath = C:\SAMS\Sams.AlarmAdministrationService\bin Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\SAMS\Sams.AlarmAdministrationService\web.config LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/f702179e/a98cc574/OSIsoft.AF.Security.UI.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/f702179e/a98cc574/OSIsoft.AF.Security.UI/OSIsoft.AF.Security.UI.DLL. LOG: Attempting download of new URL file:///C:/SAMS/Sams.AlarmAdministrationService/bin/OSIsoft.AF.Security.UI.DLL. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 
        


      Stack Trace:

      [BadImageFormatException: Could not load file or assembly 'OSIsoft.AF.Security.UI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122  [ConfigurationErrorsException: Could not load file or assembly 'OSIsoft.AF.Security.UI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12857578 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148 System.Web.Compilation.BuildManager.ExecutePreAppStart() +172 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151  [HttpException (0x80004005): Could not load file or assembly 'OSIsoft.AF.Security.UI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12979668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12819261 
        



      Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

        • Re: Could not load file or assembly 'OSIsoft.AF.Security.UI'....
          awoodall

          The error is basically referring to a x86/x64 process/assembly mismatch. This particular assembly is compiled to be bit specific unlike the AFSDK and AF UI controls which are MSIL, so it can happen. I would check the following:

           

          • Make sure the AFClient install kit is completely installed on the web server with all prerequisites. If it is installed you might try repairing the install.
          • Check what bitness the application is configured to run as. Check what bitness the IIS apppool hosting the application is configured for. Check what bitness of referenced assemblies the project is targeting. They should all match up.
          • Make sure the compiled project bin folder isn't making copies of the AF assembly files. The project should use the ones installed in the GAC by the AFClient installer.
          • Are there any specific references in the code for this assembly? I don't think you need this assembly for a WCF application if there is no WinForms UI.

           


          • Re: Could not load file or assembly 'OSIsoft.AF.Security.UI'....
            Marcos Vainer Loeff

            Hello Gerardo,

             

            Are you developing a web application? If so, why are you using the OSIsoft.AF.Security.UI assembly? Although you might be able to load it, you cannot use their objects on CSHTML/HTML pages/views.

            • Re: Could not load file or assembly 'OSIsoft.AF.Security.UI'....
              James Devine

              Dear Gerardo:

               

              I encountered the same error while deploying an ASP.net web application. I discovered the cause is essentially an incompatibility with a 32-Bit Assembly and a 64-Bit operating system. Here is how I was able to solve it:

               

              Open Internet Information Services (IIS) Manager. In the [Connections] pane click on the [Application Pools]. In the middle pane select "DefaultAppPool". Now in the [Actions] pane click [Advanced Settings...]. In the Advanced Settings dialog you will need to switch "Enable 32-Bit Applications" from False to True. Then click [OK].

               

              Next in the [Actions] pane under "Application Pool Tasks" click [Stop], wait a moment and then click [Start] (in my case I got a popup error that I was able to ignore and then had to click [Start] again, which restarted it without a problem).

               

              Upon returning to my URL in the browser the web application now launches successfully.

              1 of 1 people found this helpful
              • Re: Could not load file or assembly 'OSIsoft.AF.Security.UI'....
                David Hearn

                The OSIsoft.AF.Security.UI DLL is only used by the AFUI controls to provide the dialogs which allow the user to edit security. If you have a direct reference to this DLL in your project, you should remove it because it should not be needed.