Parse.dll 1.6.0 does not have a strong name - c#

It appears Parse.dll and Parse.NetFx45.dll from the .net 4.5 package do not have a strong name.
I have also tried signing them with my .snk, but I still have this exception when launching my app:
Could not load file or assembly 'Parse, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
StackTrace: at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at Parse.ParseClient.GetParseType(String name)
at Parse.ParseClient..cctor()
I have followed this guide to sign it personally: http://ryanfarley.com/blog/archive/2010/04/23/sign-a-.net-assembly-with-a-strong-name-without-recompiling.aspx
But it does not work.
When showing properties of the said dlls in visual studio, it does say they have a strong name.
Any idea?

To people coming across this problem, the issue was reported to the Parse developers and they have fixed it.
Happy codding folks :)

Related

C# Telerik Load Assembly Error (StartIndex cannot be less than zero.)

I have some Telerik reports that are stored in database. To convert them into Reports I used such piece of code:
private Telerik.Reporting.Report GetReportFromXml(string xmlString)
{
using (StringReader xmlReader = new StringReader(xmlString))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
object res = xmlSerializer.Deserialize(xmlReader);
return res as Telerik.Reporting.Report;
}
}
Also I have two databases with absolutely same xmlString data.
The Problem:
With first database all works fine.
With second I get error on xmlSerializer.Deserialize(xmlReader):
CurrentDomain_UnhandledException
System.IO.FileLoadException: Could not load file or assembly 'Telerik.Reporting.Design, Version=10.1.16.504, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. An argument was out of its legal range. (Exception from HRESULT: 0x80131502)
File name: 'Telerik.Reporting.Design, Version=10.1.16.504, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' ---> System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at ?A0x6aa5279c.domain_AssemblyResolve(Object __unnamed000, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at System.ComponentModel.PropertyDescriptor.GetTypeFromName(String typeName)
at System.ComponentModel.PropertyDescriptor.get_Converter()
at Telerik.Reporting.Xml.ObjectXmlReaderWriterBase.GetTypeConverter(PropertyDescriptor prop)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadValue(Object obj, PropertyDescriptor prop)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadAttributes(Object obj, PropertyDescriptorCollection props)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadProperties(Object obj)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadObject(Type type)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadXmlElement(String name)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadCollection(Object collection)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadProperties(Object obj)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadObject(Type type)
at Telerik.Reporting.Xml.ObjectXmlReader.ReadXmlElement(String name)
at Telerik.Reporting.Xml.ObjectXmlReader.Deserialize(IResourceHandler handler)
at Telerik.Reporting.Xml.XmlSerializer.Deserialize(TextReader reader, IResourceHandler resourceHandler)
at Telerik.Reporting.XmlSerialization.ReportXmlSerializer.Deserialize(TextReader reader)
I want to mention that I use the same source code and I'm totally sure that parameter xmlString is equal in both situation.
I just changing connection and error appears.
I presume it's some database setting that force assembly to load. But project is huge and don't have a clue as to how to fix this and what I should pay attention to.
Telerik Reporting assemblies are strong-name signed and the error that you are reporting looks like a version incompatibility between current assemblies. In order to rule this out, update all your references (if using NuGet install/uninstall) and ensure that all of the Telerik Reporting dependencies have the same version. I assume that the different behavior between the two data connections is a side effect, rather than the original reason behind the problem.

Why is Type.GetType throwing "Collection was modified; enumeration may not execute"?

The following line of code appears in one of the libraries we are using:
var microsoftDataSqlClientConnectionStringBuilderType =
Type.GetType("Microsoft.Data.SqlClient.SqlConnectionStringBuilder, Microsoft.Data.SqlClient", throwOnError: false);
Sometimes, when running this code through NUnit (net472), we see the following error:
System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
Stacktrace
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.Type.GetType(String typeName, Boolean throwOnError)
Why would Type.GetType throw this exception?

Cannot get Type declared in a .NET Framework assembly from a .NET Core 2 assembly

I have a .NET Core 2 console app which is performing some maintenance/upgrade work on the DB underlying a ASP.NET website running on .NET Framework 4.7.1.
The console app needs to read in the assembly-qualified type names of classes which are declared in the .NET Framework assemblies. It does this using Type.GetType("[assembly-qualified name]";
This code works perfectly well for the built-in .NET types but it throws an exception when it comes to types defined in our own assemblies. Confusingly, I can declare a variable of one of these types in the .NET Core console app but I'm unable to instantiate a Type object referencing the same type.
For example, this works...
var cs = Common.CustomerManagement.Person.CustomerStatus.ApprovedCustomer;
but this...
var ct = Type.GetType("Common.CustomerManagement.Person+CustomerStatus, Common, Version=1.0.6793.16016, Culture=neutral, PublicKeyToken=null;");
...throws the exception...
System.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
I realise that in the code which works I'm referencing an enum on the type and in the code which doesn't work I'm referencing just the type, but the working code shows that the referenced .NET Framework assembly can be loaded whereas the non-working code suggests that the type is not available to the .NET Core console app.
The problem was that the type name is the Type.AssemblyQualifiedName which includes a version number.
It's the version number which was causing the problem. Once I removed the version number and left the other information in the type name, it worked.

3rd party assembly is looking for a specific version of log4net- how do I resolve this?

I am trialing a cloud based logging system whereby I have to setup an appender for log4net in my App.config file.
It is working fine when I run it on my development PC, however when I run it on my server, I get this:
log4net:ERROR Could not create Appender [LeAppender] of type [log4net.Appender.LogentriesAppender, LogentriesLog4net]. Reported error follows.
System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
I have log4net 2.0.8.0 however it looks like this assembly is specifically referencing version 1.2.13.0 (confirmed with dotPeek).
I've never using binding redirects but I'm fairly certain this would help in this case. However, why does it work on my local machine? Is this because my local machine has a copy of that version somewhere (such as in the GAC or somewhere else?).
Also.. the documentation for logentries has nothing related to having to use a specific version of log4net.. surely they would have had this issue crop up before?

Could not load file or assembly 'Telerik.Reporting' on IIS without any references in the project to it

I have a web site on IIS. There are a lot of virtual folders with separates sites on it.
I`ve updated one of them and got "Could not load file or assembly 'Telerik.Reporting, Version=6.2.13.110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. The system cannot find the file specified."
The same errors on the other virtual folder`s sites.
Stack Trace.`[FileNotFoundException: Could not load file or assembly 'Telerik.Reporting, Version=6.2.13.110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. The system cannot find the file specified.]
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 'Telerik.Reporting, Version=6.2.13.110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +214
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 'Telerik.Reporting, Version=6.2.13.110, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601`
But in this project I don`t use Telerik at all. I created new site on IIS, deploy this project and one work well. But in the main one I still get the error.
What should I do to remove this issue from site with virtual folders? I have to deploy this project to it. I can`t delete it and create new one.
Any suggestions? Restart doesn`t help.
There could be other Web.configs that reference the telerik assembly. You would need to check all of them

Categories

Resources