1
Vote

Error when Converting DLL: System.Collections.Generic.KeyNotFoundException

description

When I tried to convert my project to C file using IL2C MyLib.dll however I got System.Collections.Generic.KeyNotFoundException.

My project referencing OpenTK, when I try to IL2C OpenTK.dll I got same error, so I suspect it comes from OpenTK.dll.

I'm using Minimal version of OpenTK that doesn't reference System.Drawing.DLL .
The assembly is attached in attachments.

Here the full errors:
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at PEAssemblyReader.MetadataModuleAdapter.SubstituteTypeSymbolIfNeeded(TypeSymbol typeSymbol, IGenericContext genericContext)
   at PEAssemblyReader.MetadataModuleAdapter.ResolveType(Int32 token, IGenericContext genericContext)
   at Il2Native.Logic.IlReader.<OpCodes>d__64.MoveNext()
   at Il2Native.Logic.IlReader.<OpCodes>d__5c.MoveNext()
   at Il2Native.Logic.OpCodeExtensions.DiscoverStructsArraysSpecializedTypesAndMethodsInMethodBody(IMethod method, ISet`1 genericTypeSpecializations, ISet`1 genericMethodSpecializations, ISet`1 structTypes, ISet`1 arrayTypes, ISet`1 usedTokenTypes, ISet`1 usedTypes, ISet`1 calledMethods, Queue`1 stackCall, ITypeResolver typeResolver)
   at Il2Native.Logic.Il2Converter.DiscoverGenericSpecializedTypesAndAdditionalTypes(IMethod method, ReadingTypesContext readingTypesContext)
   at Il2Native.Logic.Il2Converter.DiscoverGenericSpecializedTypesAndAdditionalTypes(IType typeSource, ReadingTypesContext readingTypesContext)
   at Il2Native.Logic.Il2Converter.AppendTypeAndDiscoverGenericSpecializedTypesAndAdditionalTypes(IType type, IList`1 requiredTypesByType, ReadingTypesContext readingTypesContext)
   at Il2Native.Logic.Il2Converter.FindUsedTypes(IEnumerable`1 types, IList`1 allTypes, ReadingTypesContext readingTypesContext, ITypeResolver typeResolver)
   at Il2Native.Logic.Il2Converter.ReadingTypes(IlReader ilReader, String[] filter)
   at Il2Native.Logic.Il2Converter.GenerateSource(IlReader ilReader, Settings settings)
   at Il2Native.Logic.Il2Converter.GenerateC(IlReader ilReader, String fileName, String sourceFilePath, String pdbFilePath, String outputFolder, String[] args, String[] filter)
   at Il2Native.Logic.Il2Converter.Convert(String[] sources, String outputFolder, String[] args, String[] filter)
   at Il2Native.Program.Main(String[] args)
Any ideas?

file attachments

comments

AlexDev wrote Dec 17, 2015 at 1:50 PM

1) Download source code for OpenTK.
2) OpenTK.csproj
3) remove node <Target Name="AfterBuild"> ... </Target>
4) Open OpenTK.csproj in Visual Studio 2012-2013-2015
5) Compile OpenTK.csproj
6) Convert compiled OpenTK.dll

AlexDev wrote Dec 17, 2015 at 1:51 PM

** Closed by AlexDev 12/17/2015 6:51AM

CXO2 wrote Dec 21, 2015 at 5:12 PM

The library is not working after I remove the node
It throwing NotImplementedException every time I called any functions there.

hmm it might library issue, but any ideas?

AlexDev wrote Dec 21, 2015 at 7:23 PM

you should not use the generated library as it will not work but it will generate C code which could be compiled but the next step is to remove all method which throw "NotImplementedException" and replace then with actual native API call