Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidCastException when trying to merge Oracle.ManagedDataAccess.dll #319

Closed
javeiga-iest opened this issue Mar 2, 2023 · 12 comments
Closed
Assignees

Comments

@javeiga-iest
Copy link

javeiga-iest commented Mar 2, 2023

Using ILRepack 2.0.18 and trying to merge Oracle.ManagedDataAccess.dll returns the following error:

1>  System.InvalidCastException: No se puede convertir un objeto de tipo 'System.SByte' al tipo 'System.String'.
1>     en Mono.Cecil.MetadataBuilder.GetConstantSignature(ElementType type, Object value)
1>     en Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
1>     en Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
1>     en Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
1>     en Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
1>     en Mono.Cecil.MetadataBuilder.AddTypeDefs()
1>     en Mono.Cecil.MetadataBuilder.BuildTypes()
1>     en Mono.Cecil.MetadataBuilder.BuildModule()
1>     en Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
1>     en Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
1>     en Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
1>     en ILRepacking.ILRepack.Repack()
1>     en ILRepacking.Application.Main(String[] args)

This works fine if we use the Oracle.ManagedDataAccess.dll v 19.18.0. All versions after that one returns System.InvalidCastException.

Any idea how to fix it?

@KirillOsenkov
Copy link
Collaborator

Could you please try the latest ILRepack version: https://www.nuget.org/packages/ILRepack/2.0.23

@DavidHess-ITS
Copy link

I am using ILRepack.LIB.MSBuild.Task 2.0.29 and i get this same error with latest Oracle.ManagedDataAccess.dll (21.13.0):

packages\ILRepack.Lib.MSBuild.Task.2.0.29\build\ILRepack.Lib.MSBuild.Task.targets(16,9): error : Unable to cast object of type 'System.SByte' to type 'System.String'.

@KirillOsenkov KirillOsenkov reopened this Apr 1, 2024
@KirillOsenkov KirillOsenkov self-assigned this Apr 1, 2024
@KirillOsenkov
Copy link
Collaborator

The Oracle assembly is obfuscated. There's a field a::b of type string that has an sbyte constant 32:

image

@KirillOsenkov
Copy link
Collaborator

Not sure if we want to support this case, but if we do, we're going to have to patch Cecil.

@DavidHess-ITS
Copy link

Not sure if we want to support this case, but if we do, we're going to have to patch Cecil.

For my part, I would encourage that you try to support it. We can't always control the third party assemplies we want to merge.

Can you suggest where in the Cecil code the is? Maybe that isn't obvious yet.

@KirillOsenkov
Copy link
Collaborator

It's in the stack above: Mono.Cecil.MetadataBuilder.GetConstantSignature

Cecil needs to roundtrip any assembly as is, preserving the exact bytes

Fortunately we already have a fork of Cecil, so if we do make a fix in Cecil it'll be easier

@DavidHess-ITS
Copy link

I have a patch for Cecil, i guess i should go to that repo and submit?

@KirillOsenkov
Copy link
Collaborator

nope, we have a submodule:
image

You can send a PR against this branch of my fork:
https://github.com/KirillOsenkov/cecil/tree/ilrepack

@DavidHess-ITS
Copy link

PR created. I created a test for my change, and I don't think it breaks anything else, but I am not familiar with this codebase so...

Thanks for considering it!

@KirillOsenkov
Copy link
Collaborator

Now need to bump the cecil submodule to the latest commit in the ilrepack branch

@KirillOsenkov
Copy link
Collaborator

done, this should be included in the next release

@KirillOsenkov
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants