Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Embeddinator IKVM submodule version is old, HelloWorld tutorial fails #781

Open
caquillo07 opened this issue Aug 15, 2020 · 7 comments
Open
Labels
Milestone

Comments

@caquillo07
Copy link

Tried to follow the Getting started with macOS and getting unexpected error. Removed all xamirin, mono and visual studio components and re-installed, and error persists.

Steps to Reproduce

  1. Create a new Mac Class Library project
  2. Installed Embeddinator-4000 nuget from Visual Studio for Mac
  3. Build project
  4. Embeddinate by executing ./packages/Embeddinator-4000.0.4.0/tools/objcgen csharp-hello-world/bin/Debug/csharp-hello-world.dll --target=framework --platform=macOS-modern --abi=x86_64 --outdir=output -c --debug

Expected Behavior

The framework will be placed in ~/Projects/hello-from-csharp/output/hello-from-csharp.framework.

Actual Behavior

EM0000: Unexpected error - Please fill a bug report at https://github.com/mono/Embeddinator-4000/issues

Environment

macOS - 10.15.6 Beta (19G71a)

using AppKit;
public class MyNSView : NSTextView
{
    public MyNSView()
    {
        Value = "Hello from C#";
    }
}

Build Logs

➜  csharp-hello-world ./packages/Embeddinator-4000.0.4.0/tools/objcgen csharp-hello-world/bin/Debug/csharp-hello-world.dll --target=framework --platform=macOS-modern --abi=x86_64 --outdir=output -c --debug
Symbol file /Users/Hector/Documents/code/csharp-swift-demo/csharp-hello-world/packages/Embeddinator-4000.0.4.0/tools/IKVM.Reflection.pdb doesn't match image /Users/Hector/Documents/code/csharp-swift-demo/csharp-hello-world/packages/Embeddinator-4000.0.4.0/tools/IKVM.Reflection.dll
Parsing assemblies...
	Parsed 'csharp-hello-world/bin/Debug/csharp-hello-world.dll'
Processing assemblies...
EM0000: Unexpected error - Please fill a bug report at https://github.com/mono/Embeddinator-4000/issues
IKVM.Reflection.BadImageFormatException: Exception of type 'IKVM.Reflection.BadImageFormatException' was thrown.
  at IKVM.Reflection.Reader.MetadataReader.ReadHasCustomAttribute () [0x0016f] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Metadata.CustomAttributeTable.Read (IKVM.Reflection.Reader.MetadataReader mr) [0x00006] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader.ReadTables (System.IO.BinaryReader br) [0x000ef] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader.Read (System.IO.Stream stream, System.Boolean mapped) [0x0029f] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader..ctor (IKVM.Reflection.Reader.AssemblyReader assembly, IKVM.Reflection.Universe universe, System.IO.Stream stream, System.String location, System.Boolean mapped) [0x0005d] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Universe.OpenRawModule (System.IO.Stream stream, System.String location, System.Boolean mapped) [0x00033] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Universe.OpenRawModule (System.IO.Stream stream, System.String location) [0x00001] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Universe.OpenRawModule (System.String path) [0x00016] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Universe.LoadFile (System.String path) [0x00002] in <90104beb381b4b808b5b21c02f12857c>:0
  at Embeddinator.ObjC.Embedder+<>c__DisplayClass60_0.<Generate>b__0 (System.Object sender, IKVM.Reflection.ResolveEventArgs resolve_args) [0x000d7] in /Users/donblas/Programming/Embeddinator-4000/objcgen/embedder.cs:208
  at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, System.Boolean throwOnError) [0x00067] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRefImpl (IKVM.Reflection.Metadata.AssemblyRefTable+Record& rec) [0x00084] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader.ResolveAssemblyRef (System.Int32 index) [0x00036] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.ModuleReader.ResolveType (System.Int32 metadataToken, IKVM.Reflection.IGenericContext context) [0x000ff] in <90104beb381b4b808b5b21c02f12857c>:0
  at IKVM.Reflection.Reader.TypeDefImpl.get_BaseType () [0x00035] in <90104beb381b4b808b5b21c02f12857c>:0
  at Embeddinator.ObjC.ObjCProcessor.IsSupported (IKVM.Reflection.Type t) [0x003be] in /Users/donblas/Programming/Embeddinator-4000/objcgen/objcprocessor.cs:183
  at Embeddinator.ObjC.ObjCProcessor+<GetTypes>d__13.MoveNext () [0x00069] in /Users/donblas/Programming/Embeddinator-4000/objcgen/objcprocessor.cs:193
  at Embeddinator.ObjC.Processor.Process (Embeddinator.ObjC.ProcessedAssembly a) [0x000a7] in /Users/donblas/Programming/Embeddinator-4000/objcgen/processor.cs:46
  at Embeddinator.ObjC.Processor.Process (System.Collections.Generic.IEnumerable`1[T] input) [0x0007f] in /Users/donblas/Programming/Embeddinator-4000/objcgen/processor.cs:32
  at Embeddinator.ObjC.ObjCProcessor.Process (System.Collections.Generic.IEnumerable`1[T] input) [0x00001] in /Users/donblas/Programming/Embeddinator-4000/objcgen/objcprocessor.cs:364
  at Embeddinator.ObjC.Embedder.Generate (System.Collections.Generic.List`1[T] args) [0x000fc] in /Users/donblas/Programming/Embeddinator-4000/objcgen/embedder.cs:227
  at Embeddinator.ObjC.Driver.Main2 (System.String[] args) [0x0030d] in /Users/donblas/Programming/Embeddinator-4000/objcgen/driver.cs:124
  at Embeddinator.ObjC.Driver.Main (System.String[] args) [0x00002] in /Users/donblas/Programming/Embeddinator-4000/objcgen/driver.cs:46
Debug Log:
Processing: 1 assemblies
Processing Assembly: csharp-hello-world

Example Project (If Possible)

@whitneyschmidt whitneyschmidt added the need-info Waiting for more information before the bug can be investigated label Aug 17, 2020
@whitneyschmidt whitneyschmidt added this to the Future milestone Aug 17, 2020
@whitneyschmidt
Copy link

@caquillo07 Thank you for your feedback!

Could you share the environment that you're using to build the project? If you are using VS for Windows and building remotely on a Mac. You will need to use VSMac. More information on this can be found here: #756

The easiest way to get exact version information:

  • On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
  • On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.

Then copy/paste the version information (you can use the "Copy Information" button).

We look forward to hearing from you!

@caquillo07
Copy link
Author

@whitneyschmidt Ah I completed missed all the important details there.

I am using Visual Studio for Mac, so no Windows in this case. Here is the info for my system:

macOS - 10.15.6 Beta (19G71a) at the time of build, currently at Mac OS X 10.16.0

Visual Studio:

=== Visual Studio Community 2019 for Mac ===

Version 8.7.2 (build 4)
Installation UUID: e47f73d6-6af7-4743-83b6-31901d0974d5
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 612000090

=== Mono Framework MDK ===

Runtime:
	Mono 6.12.0.90 (2020-02/d3daacdaa80) (64-bit)
	Package version: 612000090

=== Roslyn (Language Service) ===

3.7.0-6.20371.12+917b9dfae12e3b6cb266a3c062fb20a1e9d5fb06

=== NuGet ===

Version: 5.7.0.6702

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.401/Sdks
SDK Versions:
	3.1.401
	3.1.301
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	3.1.7
	3.1.5
	2.1.21

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.6 (16141)
Build 11E708

=== Xamarin.Mac ===

Version: 6.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:44:59-0400

=== Xamarin.iOS ===

Xamarin.iOS not installed.
Can't find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

=== Xamarin Designer ===

Version: 16.7.0.492
Hash: f5afe667d
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-07-10 18:42:54 UTC

=== Xamarin.Android ===

Not Installed

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
1.8.0_51
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/dev/jmt/d16-7readconfig~2
Build date: 2020-07-23 22:38:02 UTC

=== Android Device Manager ===

Version: 16.7.0.18
Hash: 4b44bc1
Branch: remotes/origin/d16-7
Build date: 2020-07-23 22:38:26 UTC

=== Build Information ===

Release ID: 807020004
Git revision: 6b86e771c92aa2615d2c2a09919bb3d4ccb69a5a
Build date: 2020-08-12 07:16:26-04
Build branch: release-8.7
Xamarin extensions: 6b86e771c92aa2615d2c2a09919bb3d4ccb69a5a

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.0.0 Darwin Kernel Version 20.0.0
    Thu Jul 30 22:49:28 PDT 2020
    root:xnu-7195.0.0.141.5~1/RELEASE_X86_64 x86_64

@whitneyschmidt whitneyschmidt added bug and removed need-info Waiting for more information before the bug can be investigated labels Aug 20, 2020
@whitneyschmidt
Copy link

Marked as a bug. I was able to reproduce this locally by following the Getting Started instructions.

@caquillo07
Copy link
Author

Thank you! Looking forward to hearing more about it later.

In the mean time, are there any known work arounds? I do have a project I was hoping this could work for.

Thanks

@whitneyschmidt
Copy link

@caquillo07 It looks like the issue is that the version of IKVM you're using is too old. Updating the code to reference the newest IKVM may solve the error.

If you want to investigate fixing this, we would be happy to guide you through making the change - let us know.

@whitneyschmidt whitneyschmidt changed the title EM0000: Unexpected error -EM0000: Unexpected error - Obj-C Hello World Embeddinator IKVM submodule version is old, HelloWorld tutorial fails Aug 31, 2020
@whitneyschmidt whitneyschmidt pinned this issue Aug 31, 2020
@caquillo07
Copy link
Author

@whitneyschmidt sorry for the super late reply, not sure how I missed this notification.

I would love to try fixing this for a project I have coming up, any help you can provide would be awesome.

Thanks!

@chamons
Copy link
Contributor

chamons commented Oct 29, 2020

Thanks for the interest!

I'd suggest joining our discord (https://aka.ms/dotnet-discord), most of the relevant people are in the #apple channel.

As a first step I expect you'd:

  • Build Embeddinator-4000 from source
  • Create a branch, and bump external/ivkm submodule to latest
  • Fix compiler and test issues associated with that
  • PR the changes for review.

We're happy to provide some guidance and answer a few questions.

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

No branches or pull requests

3 participants