I had a project up and running with the November 2011 SDK and recently upgraded to the June 2012 SDK. When I first saw the error, I attempted the obvious - remove references and add the later versions, but that didn't help. Somehow it seems that version 1.0.0.0 is still being requested. I've also attempted to remove the reference and add the old version back, but no luck.
Here's how it shows up in my code. The first Trace.WriteLine that hits now reports the following exception:
System.IO.FileLoadException was unhandled by user code Message=Could
not load file or assembly 'Microsoft.WindowsAzure.Diagnostics,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The located assembly's manifest definition
does not match the assembly reference. (Exception from HRESULT:
0x80131040) Source=mscorlib
FileName=Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35 FusionLog====
Pre-bind state information === LOG: User = NT AUTHORITY\NETWORK
SERVICE LOG: DisplayName = Microsoft.WindowsAzure.Diagnostics,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified) LOG: Appbase =
file:///F:/SVNProjects/myproject/SitePagesWebRole/ LOG: Initial
PrivatePath = F:\SVNProjects\myproject\SitePagesWebRole\bin Calling
assembly : (Unknown).
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
F:\SVNProjects\myproject\SitePagesWebRole\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: Post-policy reference: Microsoft.WindowsAzure.Diagnostics,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG:
Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/b117acb8/f2404402/Microsoft.WindowsAzure.Diagnostics.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/b117acb8/f2404402/Microsoft.WindowsAzure.Diagnostics/Microsoft.WindowsAzure.Diagnostics.DLL.
LOG: Attempting download of new URL
file:///F:/SVNProjects/myproject/SitePagesWebRole/bin/Microsoft.WindowsAzure.Diagnostics.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor
Version ERR: Failed to complete setup of assembly (hr = 0x80131040).
Probing terminated.
StackTrace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName,
ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.Type.GetType(String typeName)
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceInternal.get_Listeners()
at System.Diagnostics.TraceInternal.WriteLine(String message)
at myproject.GameAPI.Login(Int64 fbid, Int64[] friends) in F:\SVNProjects\myproject\GameLogic\GameAPI.cs:line 119
InnerException:
How can this be solved?
Check the web.config / app.config for all your roles. Make sure that you change the version number for any reference to the Microsoft.WindowsAzure.Diagnostics assembly to version 1.7.0.0
All your azure assembly references in your web/worker role projects should point to 1.7.0.0 Versions. Your ccproj files should contain
<ProductVersion>1.7</ProductVersion>
to ensure that the Azure instances contain the proper base assemblies.
You could also check if Microsoft.WindowsAzure.Diagnostics is copied to the output/azure package.
The above didn't work for me (everywhere I looked it said 1.7), instead I went through each project, removed and re added any reference that started with:
Microsoft.WindowsAzure.*
When you re-add them make sure it says version 1.7.
Related
I am attempting to create a Windows Forms Application (VS2019, VB.NET, MySQL Connector Net 8.0.23, MySQL.Data v4.5.2, Windows 10) to interface with a remote MySQL server. I am using the proper server name, username, password and database. I can connect to the database from this IP address with the same credentials on the same system using MySQL Workbench. I can also connect to the server and run queries via the Server Explorer in VS2019.
In attempting initial connection using:
conn = New MySqlConnection("server=<server>;user=<username>;password=<password>;database=<database>")
conn.Open()
I receive an error
The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception.
System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at MySql.Data.MySqlClient.MySqlConnectAttrs.InitOSDetails()
at MySql.Data.MySqlClient.MySqlConnectAttrs..cctor()
--- End of inner exception stack trace ---
at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs()
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at KDA_POS.clsDatabase.ConnOpen() in [...]\clsDatabase.vb:line 22
Obviously, the most relevant detail is
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
I have searched high and low, but any post with a suggested resolution is too old - it is for VS2017 or older, and using much older versions of MySQL Connector. It seems pretty clear that there were significant compatibility issues with VS and MySQL in early/mid 2020, and I've seen hints that there were some positive updates since then, but no actual detail.
Has anyone found a way to connect VS2019 VB.NET to MySQL in 2021? Did I miss a reference or do I need to install System.Management? Such a dll kinda sounds a bit too important to be missing... In checking if I can add a reference to System.Management, it does appear to be missing at any version.
I had the same issue. solved it by removing mysql.data package and installing mysqlconnector from nuget packages. after adding the using statement in all classes where mysql.data was previously referred everything worked fine
This is killing me. I have cleared out the offending packages, uninstalled the packages, reinstalled, attempted to add a <PackageReference>, tried targeting multiple frameworks with <targetFrameworks>... All of the things and I am still getting this error at runtime.
I have a .NET Standard 2.0 library that is being consumed by a .NET Framework 4.8 project. The framework project does not reference any of the IdentityModel.Tokens/Jwt objects. I have manually copied the assembly from the packages location in to the bin folder of the offending project and it does not seem to change the result.
Fusion Log
*** Assembly Binder Log Entry (1/7/2021 # 11:38:12 AM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable REDACTED\REDACTED\bin\Debug\REDACTED.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.IdentityModel.Tokens.Jwt, Version=6.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file: REDACTED
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = REDACTED.exe
Calling assembly : REDACTED.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: REDACTED\REDACTED\bin\Debug\REDACTED.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.IdentityModel.Tokens.Jwt, Version=6.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///REDACTED/REDACTED/bin/Debug/System.IdentityModel.Tokens.Jwt.DLL.
LOG: Assembly download was successful. Attempting setup of file: REDACTED\REDACTED\bin\Debug\System.IdentityModel.Tokens.Jwt.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.IdentityModel.Tokens.Jwt, Version=6.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Binding succeeds. Returns assembly from REDACTED\REDACTED\bin\Debug\System.IdentityModel.Tokens.Jwt.dll.
LOG: Assembly is loaded in default load context.
After getting an additional set of eyes on it, it turns out that the root project file (we do things a little differently) that references the .NET Framework project requires a reference to the assembly that wasn't being loaded.
Don't know why, but maybe something to do with MVVM and using a root project as a wrapper/driver for the application.
I spent more hours to fix this problem. I have research all ways in stackoverflow .I updated my json reference but. I couldn't solve this problem. Please help. Thanks in advance,Json version=9.0.0.0 is not fond.
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
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.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 29:
Line 30:
Line 31: var message = MessageResource.Create(
Line 32:
Line 33: to: to,
Source File: C:\Users\TexnoUsta\Documents\Visual Studio
2017\Projects\SANTEKSolutions\SANTEK.Web\Controllers\SmsController.cs
Line: 31
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
Please help. Thanks in advance,Json version=9.0.0.0 is not fond.
Also if the version "9.0.1" exists, I would rather expect "9.0.0" than "9.0.0.0".
But according to github tags of source code: https://github.com/JamesNK/Newtonsoft.Json/tags, the "9.0.0[.0]" never existed, so you will never find it, unless you create your own.
Why? Ask the creator. But if the author of that package versions his code reasonably, then 9.0.1 should be minor bugfix of fictional 9.0.0, i.e. good-enough to be used by you as replacement for non-existing 9.0.0.0.
It looks like that web (?) already did use version 9.0.0.0 ... then ask the creator of the web, where did he get it from, maybe some custom creation, or from different company, building on the Newtonsoft.Json original, but releasing with different versions.
I have a .NET 3.5 project with a corresponding unit test project.
First of all, since the Update to VS 2013 I cannot longer run the test project with MSTest. I learned that vstest.console.exe is the new preferred way to execute the tests.
Nevertheless, during the test run with vstest.console.exe which executes 550 UnitTests, all of them successful, my console gets spammed with a LOT of these exceptions:
Warning: System.Runtime.Serialization.SerializationException: Unable to find assembly 'Moq, Version=4.2.1402.2112, Culture=neutral, PublicKeyToken=69f491c39445e920'.
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
at System.AppDomain.Deserialize(Byte[] blob)
at System.AppDomain.UnmarshalObject(Byte[] blob)
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
at System.AppDomain.Deserialize(Byte[] blob)
at System.AppDomain.UnmarshalObject(Byte[] blob)
I don't know what I did wrong.
I can only guess that because the tests are executed in Isolation mode (probably because of .NET Framework 3.5), it needs to transfer some objects between app domains, and here these exceptions occur.
My Question is:
Why can't the assembly be located? The Moq.dll is right beside my unit test assembly. What can I do to prevent these hundreds of exception messages during the test run?
Update:
I was being asked to run the fusion logger alongside, and it gave me this info:
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.clr20.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Moq, Version=4.2.1402.2112, Culture=neutral, PublicKeyToken=69f491c39445e920
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Moq.DLL.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Moq/Moq.DLL.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/Moq.DLL.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/Moq/Moq.DLL.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Moq.EXE.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Moq/Moq.EXE.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/Moq.EXE.
LOG: Attempting download of new URL file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 12.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/TESTWINDOW/Extensions/Moq/Moq.EXE.
LOG: All probing URLs attempted and failed.
Now, I am asking why it does not use the Assemblies provided with my test project.
I cannot copy the Moq.dll to any of these paths, since I run multiple test projects in the same test run that use different versions of some assemblies and I could only provide one specific version here.
I was getting similar warnings on the build machine. The reason turned-out to be MockExceptions being thrown during the unit tests execution (All tests were successful even in my case, because of async-await weirdness).
Trick to identify these exceptions is to 'Debug' the unit tests instead of 'Running' (Right click and select Debug Selected Tests at project level). Fixing these MockExceptions got rid of the build warnings for me. Hope this helps.
Okay, I found the issue.
It seems that in the Moq NuGet package the Moq.dll in the lib\net35\ Folder is a dll built against .NET 4, and this cannot be loaded when the test is run in a .NET 3.5 environment.
Im using VS 2010 MVC3, I set up the web.config to connect to my remote database. When I debug its runs ok, registers, logs in fine. But when I upload it to the host i get this error:
Security Exception Description: The application attempted to perform
an operation not allowed by the security policy. To grant this
application the required permission please contact your system
administrator or change the application's trust level in the
configuration file.
Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Security.Permissions.SecurityPermission,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
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.
Stack Trace:
[SecurityException: Request for the permission of type
'System.Security.Permissions.SecurityPermission, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.]
MySql.Data.MySqlClient.MySqlConnectionStringBuilder.CreatePermissionSet()
+0 MySql.Data.MySqlClient.MySqlConnectionStringBuilder.DemandPermissions()
+38 MySql.Data.MySqlClient.MySqlConnection.PermissionDemand() +94 MySql.Data.MySqlClient.MySqlConnection.Open() +196
MySql.Web.Common.SchemaManager.GetSchemaVersion(String
connectionString) +65
MySql.Web.Common.SchemaManager.CheckSchema(String connectionString,
NameValueCollection config) +39
MySql.Web.Security.MySQLRoleProvider.Initialize(String name,
NameValueCollection config) +462
System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings
providerSettings, Type providerType) +419
Im using MySQL Connector Net 6.5.4
Thats a common Problem which a lots of people having.Thats because you build your website in Full trust level.That allows you to do nearly everything by IIS.But a lots of hosting company allows just Medium trust level.So you need to recode necessary parts of your project under Medium trust level.
Open ;
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
folder and open webconfig file,and change line;
<trust level="Full" originUrl="" />
to
<trust level="Medium" originUrl="" />
Honestly I don't have a deep knowledge about further step and your assemblies.So I can help that much.
My friend had the same problem. He managed it adding the following setting in the MySql Connection String:
includesecurityasserts=true