[Mono-dev] patch to make mcs "bundlable"

Teudimundo mynos_main at yahoo.it
Tue Oct 30 10:32:33 UTC 2012


Hi, 
I'm trying to bundle an application that uses the mcs, that's why I need to
bundle mcs as well. 
When I tried I've get the following exception: 

[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException:
Cannot be negative. 
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in
<filename unknown>:0 
  at Mono.CSharp.StaticLoader..ctor (Mono.CSharp.StaticImporter importer,
Mono.CSharp.CompilerContext compiler) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename
unknown>:0 

The code causing this is in ikvm.cs: 

   var corlib_path = Path.GetDirectoryName (typeof
(object).Assembly.Location);   
   string fx_path = corlib_path.Substring (0, corlib_path.LastIndexOf
(Path.DirectorySeparatorChar)); 
   if (compiler.Settings.StdLib) { ... 

When mcs is bundled corlib_path is empty and this cause the
corlib_path.LastIndexOf to return a -1, but 
both corlib_path and fx_path are used only inside the "if
(compiler.Setting.StdLib)" then branch. 

I then tried moving the two lines inside the if body. Passed -nostdlib to
the mcs during compilation and an explicit reference to a mscorlib.dll file.
In this way everything works. 

I thus propose to apply the patch that I'm attaching. 

Just out of curiosity, is there any reason for which fx_path is not computed
using Path.GetDirectoryName(corlib_path) (and for which corlib_path is not
checked to be not empty)?

Thanks. 
--Tommaso 

mcs.nostdlib.patch
<http://mono.1490590.n4.nabble.com/file/n4657173/mcs.nostdlib.patch>  




--
View this message in context: http://mono.1490590.n4.nabble.com/patch-to-make-mcs-bundlable-tp4657173.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list