question

KamranAli-0346 avatar image
0 Votes"
KamranAli-0346 asked KamranAli-0346 published

Microsoft.Cis.Monitoring.Query error when using Azure.AI.TextAnalytics Package

Hello,
I am building an ASP .NET Web Application using VB.NET. The application will use the Azure.AI.TextAnalytics Package to extract Health Information from a given text.
However, when I run the App using Visual Studio 2019 I keep getting the error as shown below (after the code snippet):

 Imports Microsoft.Azure
 Imports Azure.AI.TextAnalytics
 Public Class WebForm1
    
     Inherits System.Web.UI.Page
    
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
     End Sub
    
     Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
         Dim azureKC As Azure.AzureKeyCredential
         Dim azureEP As Uri
         Dim client As TextAnalyticsClient
         Dim HealthOpeartion As AnalyzeHealthcareEntitiesOperation
    
         azureKC = New Azure.AzureKeyCredential("***********************")
         azureEP = New Uri("https://eastus.api.cognitive.microsoft.com/")
         client = New TextAnalyticsClient(azureEP, azureKC)
    
     End Sub
 End Class

Here is the error detail:

 Server Error in '/' Application.
 Could not load file or assembly 'Microsoft.Cis.Monitoring.Query' 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 'Microsoft.Cis.Monitoring.Query' 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 'Microsoft.Cis.Monitoring.Query' could not be loaded.
    
    
 === Pre-bind state information ===
 LOG: DisplayName = Microsoft.Cis.Monitoring.Query
  (Partial)
 WRN: Partial binding information was supplied for an assembly:
 WRN: Assembly Name: Microsoft.Cis.Monitoring.Query | 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:/Users/Kamran/Documents/Python Projects/VBTextAnalyticsWebApp/VBTextAnalyticsWebApp/
 LOG: Initial PrivatePath = C:\Users\Kamran\Documents\Python Projects\VBTextAnalyticsWebApp\VBTextAnalyticsWebApp\bin
 Calling assembly : (Unknown).
 ===
 LOG: This bind starts in default load context.
 LOG: Using application configuration file: C:\Users\Kamran\Documents\Python Projects\VBTextAnalyticsWebApp\VBTextAnalyticsWebApp\web.config
 LOG: Using host configuration file: C:\Users\Kamran\Documents\IISExpress\config\aspnet.config
 LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:/Users/Kamran/AppData/Local/Temp/Temporary ASP.NET Files/vs/4d81e030/65f461dd/Microsoft.Cis.Monitoring.Query.DLL.
 LOG: Attempting download of new URL file:///C:/Users/Kamran/AppData/Local/Temp/Temporary ASP.NET Files/vs/4d81e030/65f461dd/Microsoft.Cis.Monitoring.Query/Microsoft.Cis.Monitoring.Query.DLL.
 LOG: Attempting download of new URL file:///C:/Users/Kamran/Documents/Python Projects/VBTextAnalyticsWebApp/VBTextAnalyticsWebApp/bin/Microsoft.Cis.Monitoring.Query.DLL.
 ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
    
 Stack Trace:
    
    
 [BadImageFormatException: Could not load file or assembly 'Microsoft.Cis.Monitoring.Query' 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.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +37
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +159
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +80
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
    System.Reflection.Assembly.Load(String assemblyString) +29
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38
    
 [ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Cis.Monitoring.Query' 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) +726
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +196
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +172
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +111
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +156
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +695
    
 [HttpException (0x80004005): Could not load file or assembly 'Microsoft.Cis.Monitoring.Query' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +660
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189


dotnet-aspnet-generalazure-text-analytics
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KamranAli-0346 Is the error due to platform target that is set on your project? Not sure if Text analytics package is the issue.
Referencing an old SO thread with a similar error.


0 Votes 0 ·

@romungi-MSFT Thanks for the lead but unfortunately it has not helped.
I went into Visual Studio --> Tools --> Options --> Projects and Solutions --> Web Projects and checked the "Use the 64 bit version of IIS Express for web sites and Projects. However, that did not solve the issues.

Any other ideas?

0 Votes 0 ·

Hi @KamranAli-0346 ,
You could try to rename the bin folder and recompile the problem.
Best regards,
Yijing Sun

0 Votes 0 ·

@YijingSun-MSFT I have tried that already :-)
Did not help, either.

Thanks.

0 Votes 0 ·
YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @KamranAli-0346 ,
BadImageFormatException usually means 64 vs 32 bit conflict. One of the assemblies is set to a specific platform i.e. 64 bit or 32 bit while the other is set or defaults to a different one.
Right click on project settings, then click on build and set the platform target from Any to x64 or x86 , according to your dll settings.

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KamranAli-0346 avatar image
1 Vote"
KamranAli-0346 answered KamranAli-0346 published

@YijingSun-MSFT and @romungi-MSFT Thanks to both of you for providing your inputs.

I solved the problem by simply deleting the entire solution directory and then restarting from scratch.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.