Could not load file or assembly 'Microsoft.Win

2019-04-06 00:59发布

My system crashed a couple of days ago, since then when I try to debug local Azure environment I get this error 'Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics' or one of its dependencies'.

I have reinstalled the following (Windows Azure tools for MS VS 2012 June 2012 sp1, Windows Azure emulator - June 2012, Windows Azure Librarires for .net - June 2012).

Still having the same issues, any suggestions.

=== Pre-bind state information ===
LOG: User = ...........
LOG: DisplayName = Microsoft.WindowsAzure.Diagnostics
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.WindowsAzure.Diagnostics | 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:/Projects/Client/Connection Intelegence/CICloud/CIWebRole/
LOG: Initial PrivatePath = C:\Projects\Client\Connection Intelegence\CICloud\CIWebRole\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\Client\Connection         Intelegence\CICloud\CIWebRole\web.config
LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\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/9cc4e65f/1fb72ae3/Microsoft.WindowsAzure.Diagnostics.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/9cc4e65f/1fb72ae3/Microsoft.WindowsAzure.Diagnostics/Microsoft.WindowsAzure.Diagnostics.DLL.
LOG: Attempting download of new URL file:///C:/Projects/Client/Connection Intelegence/CICloud/CIWebRole/bin/Microsoft.WindowsAzure.Diagnostics.DLL.
LOG: Using application configuration file: C:\Projects\Client\Connection Intelegence\CICloud\CIWebRole\web.config
LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35



[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
[FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
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 'Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
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) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
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 'Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

5条回答
劳资没心,怎么记你
2楼-- · 2019-04-06 01:33

It looks like this is happening when your application starts. Take a look at your web.config, do you have a trace listener pointing to the Microsoft.WindowsAzure.Diagnostics assembly? That might be the reason why your application is not working.

First, take a look at your assembly references and delete Microsoft.WindowsAzure.Diagnostics should it be present (just to be sure we don't use old versions). Then, add a reference to Microsoft.WindowsAzure.Diagnostics, but make sure this is version 1.7.0.0.

You should find the right version of this assembly in: C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\ref

查看更多
smile是对你的礼貌
3楼-- · 2019-04-06 01:36

It might be best to check the properties of Microsoft.WindowsAzure.Diagnostics to see which version you're using. Mine says 2.8.0.0 when I plugged that into the Web.config element mentioned by Dan and Taylor above it worked. 2.7.0.0 didn't work for me 2.8.0.0 did but tomorrow it may be otherwise ;-).

查看更多
神经病院院长
4楼-- · 2019-04-06 01:45

I looked at the references and discovered that Microsoft.WindowsAzure.Diagnostics is used by the roles. In my case, the roles were using 2.8.0.0. I then opened the app.config of each role and set the add for Microsoft.WindowsAzure.Diagnostics to that same version.

  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
查看更多
小情绪 Triste *
5楼-- · 2019-04-06 01:50

Adding to Sandrinio's answer (sorry I don't have privilege) I had a similar error where 1.7.0.0 was being referenced but this section in my web.config pointed to version 1.0.0.0

<system.diagnostics>
<trace>
  <listeners>
    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      name="AzureDiagnostics">
      <filter type="" />
    </add>
  </listeners>
</trace>

I commented it out and the problem was resolved.

查看更多
贪生不怕死
6楼-- · 2019-04-06 01:58

I know this is an old topic but it's still the top Google result for "Could not load file or assembly Microsoft.WindowsAzure.Diagnostics", so here is what I did:

This was happening to me with the Azure SDK 2.7.1 and Visual Studio 2013. Somewhere between upgrading to Windows 10 and Azure SDK 2.7, something didn't get installed right. I tried reinstalling the Azure SDK, upgrading to Visual Studio 2015 but neither worked. I finally had to change the following line in my app.config:

    <system.diagnostics>
    <trace>
        <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
                <filter type="" />
            </add>
        </listeners>
    </trace>
</system.diagnostics>

to

    <system.diagnostics>
    <trace>
        <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
                <filter type="" />
            </add>
        </listeners>
    </trace>
</system.diagnostics>

Notice the change from "2.7.0.0" to "2.5.0.0". For me, Microsoft.WindowsAzure.Diagnostics 2.7.0.0 DLL did not exist. Reverting back to 2.5.0.0 works fine. I'd still like to find the root cause but I have more important things to move on to. Hope this helps!

查看更多
登录 后发表回答