[Mono-list] Where is documentation for newbies?

Ian Norton ian.norton-badrul at thales-esecurity.com
Mon Jul 2 09:56:30 UTC 2012


On 30/06/2012 02:16, Sduibek wrote:
> I am very interested in using 'mkbundle --deps file.cs' to see if I can
> effectively get a static executable for a small project I'm working on, but
> the errors I get when trying to do this make no sense to me. And,
> unfortunately, i have found mono thus far to be incredibly un-user-friendly
> and the documentation to be non-existent, and when it exists, very hard to
> track down. I am not trying to be disrespectful but it makes things
> needlessly frustrating to not have a StartHere.txt or something to that
> effect.
http://www.mono-project.com/Guide:Running_Mono_Applications

That was the first hit for mkbundle on google. Though reading further 
your email I feel you may have been a bit mislead by what it does.

> The particulars:
> Running v2.10.8 on Windows 7 Ultimate
> The basic Hello.cs compiles and executes properly.
> getting error CS0234: The type or namespace name '(getting one each for
> Data, Drawing, and Windows)' does not exist in the namespace 'System'. Are
> you missing an assembly reference?
Was this compiling on the command line with gmcs or csc? Or in monodevelop?

Like the windows compilers, you will need to tell gmcs to look for 
assemblies. eg:

gmcs foo.cs /target:library -reference:System.Drawing

See also: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx

For compiler error messages in general you can google the error number ( 
"CS0234" ):

http://msdn.microsoft.com/en-us/library/0e92xd7b(v=vs.71).aspx 
<http://msdn.microsoft.com/en-us/library/0e92xd7b%28v=vs.71%29.aspx>

> I spent several hours trying to find answers on where to go with that error
> and got nowhere. At one point I was advised in the Mono command prompt to
> check the GTK_PKG_something setting/variable, but, of course, there's no
> documentation that I could find anywhere telling where to actually set this
> variable.
Environment variable? ISTR You set those on windows 7 by searching for 
"environment variables" on the start menu and running the appropriate 
control panel thing that it finds.

What you may have noticed is that mono also supports a thing called 
"pkg-config" which is a system that helps developers distribute build 
settings and compiler flags. You tell the mono compilers to use it by doing:

gmcs -pkg:dotnet

Which the compiler (after running pkg-config and seeing the result) will 
probably expand to:

-r:Accessibility.dll -r:cscompmgd.dll -r:Microsoft.VisualC.dll 
-r:System.Configuration.Install.dll -r:System.Data.dll 
-r:System.Data.OracleClient.dll -r:System.Design.dll 
-r:System.DirectoryServices.dll -r:System.dll 
-r:System.Drawing.Design.dll -r:System.Drawing.dll 
-r:System.EnterpriseServices.dll -r:System.Management.dll 
-r:System.Messaging.dll -r:System.Runtime.Remoting.dll 
-r:System.Runtime.Serialization.Formatters.Soap.dll 
-r:System.Security.dll -r:System.ServiceProcess.dll -r:System.Web.dll 
-r:System.Web.Services.dll -r:System.Windows.Forms.dll -r:System.Xml.dll 
-r:System.Configuration.dll -r:System.Core.dll -r:System.Xml.Linq.dll 
-r:System.Data.DataSetExtensions.dll -r:System.Data.Linq.dll 
-r:System.Data.Services.dll -r:System.Web.Abstractions.dll 
-r:System.Web.Routing.dll -r:System.Web.DynamicData.dll 
-r:System.ComponentModel.DataAnnotations.dll

> Do the designers of Mono assume I already know the ins and outs of Linux or
> something? I don't understand. I literally just need to run mkbundle for a
> specific project and see if it works or not. That's all. What's most
> furstrating of all is I got the plugin for Visual Studio, and can
> successfully run this project through Mono using the menus in VS, but again
> it's very unclear how to compile it from there, versus just doing a test
> run.
If you have a solution and set of projects you can build these in 
VStudio or monodevelop or using msbuild from the command line or using 
xbuild or mdtool instead. For the most part things are quite similar to 
developing .net projects for windows, only special cases ( such as 
mkbundle and native interop ) are specific to the platforms you wish to 
target.

If you want to deploy a mono-compiled project built using windows 
mkbundle probably is not what you are looking for. You can think of 
mkbundle as a tool that helps you generate unmanaged (native) object and 
wrapper files that you can use to embed mono and your assemblies into a 
larger program (or just a single combined exe+mono) running on the same 
platform ( mkbundle on windows will target windows, linux for linux, 
apple for apple etc )

If you want to write some .net software and deploy it on a linux machine 
or a mac then you are best off compiling on those systems and shipping 
the resulting binaries from there. You should have a look at MoMa - 
http://www.mono-project.com/MoMA as your application may be dependant on 
unmanaged libraries that are not present on your target platform.

If you do not depend on anything tied to unmanaged code or special 
libraries ( or directory path separators ) then you may be able to build 
on windows in vstudio and just run the resulting binaries on mono ( for 
most cases and even most winforms code you can happily do this ). If it 
is more than this then I understand that cross platform builds and 
deployment isn't an easy thing, it would be nice if it were as simple as 
running mkbundle but it isn't.

Have Fun

Ian


More information about the Mono-list mailing list