VS2022 Installer: Impossible to install/repair because of System.Numerics and/or Newtonsoft.Json.Utilities.ConvertUtils exception - exception

This issue started today (or very recently) with a .NET 4.7.2 project that stopped running on my Win10, VS2022 Enterprise machine complaining about some missing or mismatch version of System.Numerics library. Automatic binding redirect was already enabled.
When I launched VS Installer, nothing showed up (neither installed nor available). However VS2022 was still running ok. The more I tried to fix things, the worse it got. I already wasted hours trying to reinstall, reinstall online, repair, uninstall from add/remove programs, uninstall manually using installcleanup.exe, renaming Installer folder, removing all assemblies from the GAC, etc.
To make it short, the error that shows up during Installer installation is the following:
Unable to acquire update installer
The error in the logs is always the same:
VisualStudio Bootstrapper:15/07/2022 14:09:48: Caught Exception: Type = TypeInitializationException,
Message = The type initializer for 'Newtonsoft.Json.Utilities.ConvertUtils' threw an exception.,
StackTrace = at Newtonsoft.Json.Utilities.ConvertUtils.GetTypeCode(Type t, Boolean& isEnum)
at Newtonsoft.Json.Serialization.DefaultContractResolver.IsJsonPrimitiveType(Type t)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Microsoft.VisualStudio.Setup.Utility.JsonUtility.ParseNameValuePairJson(String jsonContents)
at Microsoft.VisualStudio.Setup.Utility.JsonUtility.ParseNameValuePairJsonFile(IServiceProvider services, String filePath)
at Microsoft.VisualStudio.Setup.Bootstrapper.Program.Parse(String[] args, IServiceProvider serviceProvider, IC2RSignatureReaderInterop c2rSignatureReader, String entryAssemblyProcessName, String entryAssemblyProcessFullName)
InnerException:Type = FileNotFoundException,
Message = Could not load file or assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.,
StackTrace = at Newtonsoft.Json.Utilities.ConvertUtils..cctor()
Note: I already looked up this issue a lot, so please do not suggest obvious widely referenced solutions like "Add/Remove programs" or "Repair button". Also the "Report problem" button on the installer window that I am able to launch by renaming installer folder does not work. Offline installation via command line also does not work.
Has anyone already experienced this issue and can propose a solution other than reinstalling the whole OS? It looks the installer is not able to parse some temp/boostraper.json file because of this exception, but I have no idea how to fix this.

Turns out I did remove a GAC, but that was not the GAC (at least not the only one). Based on another answer and MS forums, deleting every GAC* folder from C:\Windows\assembly\ seems to have done the trick. The "other one" was somewhere in AppData folder.

Related

The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception

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

how to resolve ResolveLibraryProjectImports" task failed unexpectedly Exception

ResolveLibraryProjectImports" task failed unexpectedly
System.IO.FileNotFoundException Could not load assembly
I have tried to resolve it like clean bin, obj rebuild again said in the previous results of this issue but it doesn't work for me. Does anyone have a solution for this issue, please help me.
Note: I am having an error in Mono.Android in the References of portable code is this the problem and how to resolve this also?
This is the error I get:
Error The "ResolveLibraryProjectImports" task failed unexpectedly. System.IO.FileNotFoundException: Could not load assembly 'SampleProject, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'SampleProject.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() SampleProject.Android Build
=> delete all from C:\Users\username\AppData\Local\Xamarin
=> delete .vs folder
=> restart visual studio in run as admin(if not).
=> clean and rebuild.
Mono.Android is purely a native Android dll for Xamarin.Android
using this in your portable project will throw an error (Of Course.)
This might be the issue if the error still persists after removing the dll then I would suggest you remove the bin obj folders and clean build and in case it still persists you should upload the output window for the debug build as well as error list explanation for this particular error.

EF6 for MySql InvalidOperationException

This seems to be a common error but none of the fixes I have seen yet have worked. I have two VS2015 EF6 "code first from database" solutions on my PC which have identical models and app.config files. They both access the same database. One runs, and the other throws this exception.
The Entity Framework provider type
'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6'
registered in the application config file for the ADO.NET provider
with invariant name 'MySql.Data.MySqlClient' could not be loaded. Make
sure that the assembly-qualified name is used and that the assembly is
available to the running application. See
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
The exception is thrown from public virtual IList<NamedDbProviderService> DbProviderServices
It seems that copying a working solution from one PC to another provokes this exception as does checking out the solution file from Git. The only thing I can think of is that there is something wrong with the NuGet package restoration but deleting or uninstalling the packages or the package config and manually replacing them does not fix it.
The issue seems to be that the EF driver for MySql is not loading when the config is parsed. Adding the following code to the main program fixes it.
/// <summary>
/// Force the MySql.Data.Entity Assembly to be loaded
/// or the app.config file will not load
/// No need to call this function
/// </summary>
public static void Fix()
{
var name = MySql.Data.Entity.MySqlProviderInvariantName.ProviderName;
}

Unable to cast COM object of type 'System._COMObject' to interface type

I have 3 SSIS packages. Two out of the 3 SSIS packages work perfectly, the third. Which is a copy of the 2nd one, except changing connection strings keeps throwing the problem:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSObject100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D4E5AF42-7999-473C-8082-6EFC676953C4}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
It has been doing this ever since I copied the package over. I have followed through online guides and run the regsvr32 dts.dll and this said it was successful but nothing has changed. I still get the error, why is this?
The SSIS package seems to validate my containers, it takes a long time to do this compared to the other two and then fails later on in the validation throwing the above error message.
You can't just copy the package, but you need additionally to change the name and generate new GUID (which identifies the COM object) for this package. Check this MSDN article for more info.
Here is the workaround: Solution Explorer -> right click project ->properties->debugging->Run64bitRuntime->set to false.
I hope it helps others. The solution worked for me:
I registered the assembly using the gacutil.exe. My SSIS project target server version was SQL 2012. So, I was using the DTSPipelineWrap.dll version 11.0. I opened the "Developer Command Prompt for VS2015" in Administrator mode, then typed the following command: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe /i "C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll"
Then from my SSIS script task, References--> I removed the existing DTSPipelineWrap which was using the assembly from the location "C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll". Then in the References folder, right click-->Add Reference-->Browse find the assembly from the location "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap\v4.0_11.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.DTSPipelineWrap.dll"
Click Ok. Rebuild the code and executed the package. It has worked for me.
In my case this is was a validation overload/timeout, the package contained references to hundreds of tables.
Opening the offending data flow forced re-validation and cleared the error.
Project --> Properties --> Configuration Properties --> Debugging
and then change Run64BitRuntime to False under Debug Options
In case this might help someone: I got this error due to timeout issues caused by a poorly optimised query. There was nothing inherently wrong with the SSIS package and it ran fine once i fixed the problem in the DB Source.

System.Security.SecurityException being thrown on initializing StructureMap bootstrapper

I am running a .NET 4.0 web application locally using the Visual Studio Development Server (built in web server with VS2010), and for the last couple months, my StructureMap bootstrapper file has worked perfectly.
I'm using StructureMap 2.6.1
I have not changed the Bootstrapper file or the Web.config file, and suddenly, I'm getting this strange error when trying to start up my web application.
Here is the error being thrown from the website:
it's a bit tough to read. It says:
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 Failed.
here is the code in my bootstrapper file:
public class BootStrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry<ProductRegistry>();
});
}
}
public class ProductRegistry : Registry
{
public ProductRegistry()
{
For<IFirmRepository>()
.Use<FirmRepository>().Ctor<string>("connectionString").Is(ConfigurationManager.ConnectionStrings["FeesAndFlows"].ConnectionString);
For<ICryptographyService>()
.Use<Rijndael>();
For<IUserRepository>()
.Use<UserRepository>().Ctor<string>("connectionString").Is(ConfigurationManager.ConnectionStrings["FeesAndFlows"].ConnectionString);
For<IAuthenticationService>()
.Use<AuthenticationService>();
For<ILogger>()
.Use<DatabaseLogger>();
}
}
The error is being thrown on this line:
x.AddRegistry<ProductRegistry>();
I've already tried adding each of these lines to my Web.config file, one at a time, and they didn't fix the problem:
<trust level="Full" />
and
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
</securityPolicy>
Does anyone have any ideas or might have heard of a problem like this? It's pretty important, b/c without StructureMap starting up correctly, my entire application will not run.
Thanks,
Mike
UPDATE:
Ok, so it appears my problem is local. Other developers here can download the code, and runs it just fine on their local machines. Weird. They bootstrap StructurMap just fine and all instances are resolved...
Any ideas on why just my machine can't bootstrap StructureMap when running in debug mode locally for my web project?
Are you running the code from a network drive by any chance (ie is your documents folder redirected onto a network drive)? Are you in an enterprise environment running on a domain?
If the former it's likely that the code is running in the intranet security context. If the former isn't true but the later is, then its quite possible that a network administrator has changed the enterprise wide CAS policy.
Okay, so this was the problem. The StructureMap.dll was blocked by Win 7. I don't know how is become blocked or where it became blocked, but apparently, when I downloaded the StructureMap.zip file onto my system, the .zip file was blocked, which in turn, led to all the items extracted from the .zip file being blocked as well.
Every time I unblocked it, it went back to blocked when I tried to run the web app.
The way I fixed it was to go back to the original .zip file, unblock it, extract it, and then replace my StruectureMap.dll reference with one that was not blocked.
Insane.
I don't even know WHAT causes file to suddenly become blocked or what process in Windows 7 determines what file(s) should be blocked, but this strange operating system "feature" cost me a day's worth of work.
I had the exact same issue at the exact same place, ObjectFactory.Initialize:
Server Error in '/X.ServiceHost' Application.
Inheritance security rules violated while overriding member:
'StructureMap.StructureMapException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security
accessibility of the overriding method must match the security
accessibility of the method being overriden.
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.TypeLoadException: Inheritance security
rules violated while overriding member:
'StructureMap.StructureMapException.GetObjectData(System.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)'. Security
accessibility of the overriding method must match the security
accessibility of the method being overriden.
Getting the latest StructureMap package from NuGet (2.6.4.1) fixed the issue.
StructureMap NuGet Package