Bug 58914 - System.NullReferenceException: Object reference not set to an instance of an object
Summary: System.NullReferenceException: Object reference not set to an instance of an ...
Status: RESOLVED ANSWERED
Alias: None
Product: Tools
Classification: Mono
Component: mkbundle ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-20 22:08 UTC by Arthur Khusnutdinov
Modified: 2017-09-22 20:23 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Code, that fails to compile. (2.34 MB, application/zip)
2017-08-20 22:14 UTC, Arthur Khusnutdinov
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Arthur Khusnutdinov 2017-08-20 22:08:36 UTC
Hello.

I am trying to build my app on Ubuntu 17 with command 

mkbundle -o hello  bin/Debug/"TS4 STBL Editor.exe" -L /usr/lib/mono/4.0-api/ --static --deps

But it fails with error about generics:

root@ubuntuForMonoTest:/home/art/Source# mkbundle -o hello  bin/Debug/"TS4 STBL Editor.exe" -L /usr/lib/mono/4.0-api/ --static --deps

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <e959aabab32045e89c53037ae7c01bc8>:0
  at MakeBundle.Main (System.String[] args) [0x00d5f] in <e959aabab32045e89c53037ae7c01bc8>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <e959aabab32045e89c53037ae7c01bc8>:0
  at MakeBundle.Main (System.String[] args) [0x00d5f] in <e959aabab32045e89c53037ae7c01bc8>:0


I found another similar issue here https://bugzilla.xamarin.com/show_bug.cgi?id=51650 .

Can you fix this issue?

Thank you!
Comment 1 Arthur Khusnutdinov 2017-08-20 22:14:22 UTC
Created attachment 24318 [details]
Code, that fails to compile.

Code, that fails to compile.
Comment 2 Ludovic Henry 2017-09-01 00:00:38 UTC
Alexander, could you please take a look and confirm if it's related to mkbundle?
Comment 3 Hin-Tak Leung 2017-09-01 22:53:08 UTC
The user's usage of mkbundle is wrong - removing "-L /usr/lib/mono/4.0-api/", then it should work.

The *-api/*.dll are stubs, they cannot be used for embedding. You can run mcs with -L *-api stubs, but to embed and gain full functionality, you must use real dll's.
Comment 4 Arthur Khusnutdinov 2017-09-01 23:00:16 UTC
Hello.
How can I specify version of Mono dlls to be embed (I thought, that it is realized with -L option)?
Thank you!
Comment 5 Arthur Khusnutdinov 2017-09-01 23:02:41 UTC
And what are "real ddls" and how can I pass path to them to mkbundle.
I remember, that I couldn't be able to build anything with mkbundle without -L option.
Comment 6 Hin-Tak Leung 2017-09-01 23:21:27 UTC
Size difference between the real dll's and stub dll's, on linux, mono 4.8.x - note directory is called "4.5", the other directory is called "4.5-api":

$ find /usr/lib/mono/4.5* -name 'I18N*'  -follow -ls
  2022177     36 -rwxr-xr-x   1  root     root        36352 Aug  7 21:59 /usr/lib/mono/4.5/I18N.Other.dll
  2022169    668 -rwxr-xr-x   1  root     root       683520 Aug  7 21:59 /usr/lib/mono/4.5/I18N.CJK.dll
  2022173     32 -rwxr-xr-x   1  root     root        32768 Aug  7 21:59 /usr/lib/mono/4.5/I18N.MidEast.dll
  1756030     40 -rwxr-xr-x   1  root     root        39936 Aug  7 21:59 /usr/lib/mono/4.5/I18N.dll
  2022181    180 -rwxr-xr-x   1  root     root       182272 Aug  7 21:59 /usr/lib/mono/4.5/I18N.Rare.dll
  1756027     72 -rwxr-xr-x   1  root     root        71168 Aug  7 21:59 /usr/lib/mono/4.5/I18N.West.dll
  1755749     16 -rwxr-xr-x   1  root     root        12800 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.Other.dll
  1755747     20 -rwxr-xr-x   1  root     root        18432 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.CJK.dll
  1755748     12 -rwxr-xr-x   1  root     root        11264 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.MidEast.dll
  1755752     16 -rwxr-xr-x   1  root     root        15360 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.dll
  1755750     20 -rwxr-xr-x   1  root     root        17408 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.Rare.dll
  1755751     16 -rwxr-xr-x   1  root     root        12800 Aug  7 22:01 /usr/lib/mono/4.5-api/I18N.West.dll

don't know what's the directory layout on mono 5.x is like and will not be upgrading for a while yet.
Comment 7 Arthur Khusnutdinov 2017-09-01 23:57:41 UTC
Thank you again!
Comment 8 Arthur Khusnutdinov 2017-09-07 10:25:53 UTC
Hin-Tak Leung, what are the "real ddls" and how can I pass path to them to mkbundle?
I remember, that I couldn't be able to build anything with mkbundle without -L option.
Comment 9 Hin-Tak Leung 2017-09-07 19:14:02 UTC
> Hin-Tak Leung, what are the "real ddls" and how can I pass path to them to 
> mkbundle? I remember, that I couldn't be able to build anything with mkbundle 
> without -L option.

This was apparently annnounced in the release notes of mono 4.4.0 (I was going through the release notes for something else to keep me up to date since the last time I looked at them, which was about a year ago).

See
http://www.mono-project.com/docs/about-mono/releases/4.4.0/
which explains it.

Basically "4.5" is where the real ones are, all the *-api, before and after (2.0-api, 3.5-api, 4.0-api, 4.5-api, 4.6-api, 4.7-api) are stubs.

You shouldn't need to pass them specially to mkbunndle...