|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Howto detect os?Hi
is there a way to detect, if the app runs under linux or osx? Environment.OSVersion.Platform.ToString() sends in both cases "Unix" Thanks Andreas |
|
|
Re: Howto detect os?On Sun, Sep 13, 2009 at 3:45 PM, Heertsch <heertsch@...> wrote:
> > Hi > is there a way to detect, if the app runs under linux or osx? > > Environment.OSVersion.Platform.ToString() sends in both cases "Unix" In MD we use some detection code factored out of Managed.Windows.Forms/XplatUI: http://anonsvn.mono-project.com/viewvc/trunk/monodevelop/main/src/core/Mono.Texteditor/Mono.TextEditor/Platform.cs?view=markup -- Michael Hutchinson http://mjhutchinson.com _______________________________________________ Mono-osx mailing list Mono-osx@... http://lists.ximian.com/mailman/listinfo/mono-osx |
|
|
Re: Howto detect os?I removed the GTK# reference and did some cosmetics (your code won't start on my VisualStudio) (see code below). It works fine in Visual Studio and with MD on OS X. But if I try to start it in MD with OpenSuse I get: (Back translation from German) Error loading project foo.csproj: Could not set property 'Policies' in type 'DotNetProject' No idea, what that means. (Probably it does not depend on the code below.) Andreas using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace Basal.Code{ public static class Platform{ [DllImport("libc")] static extern int uname(IntPtr buf); static private bool mIsWindows; static private bool mIsMac; static private bool mIsX11; public enum OS {Windows, Mac, X11,unknown}; static public OS GetOS(){ if(mIsWindows=(System.IO.Path.DirectorySeparatorChar == '\\'))return OS.Windows; if(mIsMac=(!mIsWindows && IsRunningOnMac()))return OS.Mac; if(!mIsMac && System.Environment.OSVersion.Platform == PlatformID.Unix)return OS.X11; return OS.unknown; } //From Managed.Windows.Forms/XplatUI static bool IsRunningOnMac(){ IntPtr buf = IntPtr.Zero; try{ buf = Marshal.AllocHGlobal(8192); // This is a hacktastic way of getting sysname from uname () if (uname(buf) == 0){ string os = Marshal.PtrToStringAnsi(buf); if (os == "Darwin")return true; } } catch { } finally{ if (buf != IntPtr.Zero) Marshal.FreeHGlobal(buf); } return false; } } } |
|
|
Re: Howto detect os?On Mon, Sep 14, 2009 at 1:30 PM, Heertsch <heertsch@...> wrote:
> But if I try to start it in MD with OpenSuse I get: (Back translation from > German) > Error loading project foo.csproj: Could not set property 'Policies' in type > 'DotNetProject' > No idea, what that means. (Probably it does not depend on the code below.) That shouldn't affect your code. It's just a warning from the project loader. Could you file a bug with the full error message? -- Michael Hutchinson http://mjhutchinson.com _______________________________________________ Mono-osx mailing list Mono-osx@... http://lists.ximian.com/mailman/listinfo/mono-osx |
|
|
Re: Howto detect os?Yes your solution delivers also X11 for OpenSuse (if I use mono and not MD) ups never done! Howto do that? (the above text is the full msg) Andreas |
|
|
Re: Howto detect os?On Mon, Sep 14, 2009 at 5:58 PM, Heertsch <heertsch@...> wrote:
> > > Michael Hutchinson wrote: >> >>> Error loading project foo.csproj: Could not set property 'Policies' in >>> type >>> 'DotNetProject' >>> No idea, what that means. (Probably it does not depend on the code >>> below.) >> >> That shouldn't affect your code. It's just a warning from the project >> loader.Yes your solution delivers also X11 for OpenSuse (if I use mono and >> not MD) > > Michael Hutchinson wrote: >> Could you file a bug with the full error message?ups never done! Howto do >> that? (the above text is the full msg) http://monodevelop.com/Developers#Reporting_Bugs There could be more in the MD log at ~/.config/MonoDevelop/log -- Michael Hutchinson http://mjhutchinson.com _______________________________________________ Mono-osx mailing list Mono-osx@... http://lists.ximian.com/mailman/listinfo/mono-osx |
| Free embeddable forum powered by Nabble | Forum Help |