Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

.net/Mono Cross platform compatibility advice


  • Please log in to reply
2 replies to this topic

#1 JosiahK

JosiahK

  • Members
  • 269 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:09:49 AM

Posted 15 May 2011 - 02:28 PM

A few years back I wrote an encrypted computer diary program in VB.net as a birthday present for a friend. Recently however she's switched to using Ubuntu on her main computer, and asked whether the program may be induced to work on that platform. My understanding is that the Linux compatible Mono system is capable of executing .net bytecode, so the answer should be yes. However the program just crashes when I try to run it, and doesn't compile with monodevelop on Linux. I had a shot at rewriting the entire thing in C# which monodevelop is meant to be better suited for, but that brought in more complications than I'd anticipated including critical differences in string handling and the program not then running on Windows :smash: .

I've downloaded MoMA and tested my original Windows version, to find that it had 143 methods missing and a further 20 marked with MonoTodo! No wonder it didn't run! I've found and been looking through this guide, and I want to edit the code so that it will run on either platform. I'm looking for any further advice on how to ensure compatibility across the two platforms. I'm also wondering in particular how to find out what will be implemented in mono to replace my unsupported code with, and more importantly what code some of the errors are talking about in the first place.

e.g.
"void Main (String[]) void WindowsFormsApplicationBase.Run (String[])"
"void OnCreateMainForm () void WindowsFormsApplicationBase.set_MainForm (Form)"


I have an Ubuntu VM available for testing purposes.
Quod non mortiferum, fortiorem me facit.
I don't read minds. Please help everyone by answering any questions and reporting on the results of any instructions. Query any concerns and explain problems or complications.

BC AdBot (Login to Remove)

 


#2 JosiahK

JosiahK
  • Topic Starter

  • Members
  • 269 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:09:49 AM

Posted 16 May 2011 - 09:12 AM

Update & additional information.

I've gone through the errors, and about half of them were string functions (left, asc, etc) that I could readily simulate myself. There were also a few math functions and datetime functions that I can deal with. The remaining 70 or so problems can be fitted into one of the following categories:



File handling --- reading, writing, and generally anything to do with the file system doesn't seem to be supported. Given the nature of the program this is the most serious.
Settings --- The inbuilt my.settings capacity, which I've used primarily for appearance preferences, doesn't seem to exist. If necessary, and if I can get working filesystem code, I can create a new settings file.
VB settings --- 15 issues that don't seem to appear in my code but somewhere else in Visual Studio.
void Main (String[]) 	bool WindowsFormsApplicationBase.get_UseCompatibleTextRendering ()
void Main (String[]) 	void WindowsFormsApplicationBase.Run (String[])
void OnCreateMainForm () 	void WindowsFormsApplicationBase.set_MainForm (Form)
void .ctor () 	void WindowsFormsApplicationBase..ctor (AuthenticationMode)
void .ctor () 	void ShutdownEventHandler..ctor (Object, IntPtr)
void .ctor () 	void WindowsFormsApplicationBase.add_Shutdown (ShutdownEventHandler)
void .ctor () 	void WindowsFormsApplicationBase.set_IsSingleInstance (bool)
void .ctor () 	void WindowsFormsApplicationBase.set_EnableVisualStyles (bool)
void .ctor () 	void WindowsFormsApplicationBase.set_SaveMySettingsOnExit (bool)
void .ctor () 	void WindowsFormsApplicationBase.set_ShutdownStyle (ShutdownMode)
void .ctor () 	void Computer..ctor ()
T Create__Instance__ (T) 	string Utils.GetResourceString (string, String[])
T Create__Instance__ (T) 	void ProjectData.SetProjectError (Exception)
T Create__Instance__ (T) 	string Utils.GetResourceString (string, String[])
T Create__Instance__ (T) 	void ProjectData.ClearProjectError ()

Quod non mortiferum, fortiorem me facit.
I don't read minds. Please help everyone by answering any questions and reporting on the results of any instructions. Query any concerns and explain problems or complications.

#3 JosiahK

JosiahK
  • Topic Starter

  • Members
  • 269 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:09:49 AM

Posted 14 June 2011 - 04:08 PM

I've finally found my way through the mess, and I'm posting my findings for future reference.

The first change to make things easier is to set the .net version for the project to an earlier one (.net 2). This allows you to use the powerful Visual Studio debugging facilities to find new additions to the language, which in the vast majority of cases aren't supported by MONO.


The second issue was rather simple being that the = sign doesn't work for strings, so anything that read
if firstString = SecondString then
had to be rewritten
if firstString.Equals(SecondString)


The third thing that I discovered was that the most likely keywords not to be supported are old QBasic or VBS commands left in for backward compatibility. For example the rnd() function doesn't work, and has to be replaced with the Object Orientated Random Class. The My class is also limited to VB, so things like My.Settings and My.Computer.FileSystem didn't work. Again it is a simple matter to import the IO namespace and use the file classes it contains. I didn't find a way to use Settings, but they can be easily stored in an application defined settings file.


One problem that I did have with the program under MONO was that it always exits when the startup form closes, even though Windows worked fine with that feature. This was the task that took the most reworking as the entire interface had to be set up to work on one form. I suppose it's a sign of bad programming practice that my UI was so tangled with my code in the first place.



The only noticeable difference left between the program run under .Net and that run with Mono is that the Visual Styles don't work, Giving it a boxy sort of Windows 98 look.
Quod non mortiferum, fortiorem me facit.
I don't read minds. Please help everyone by answering any questions and reporting on the results of any instructions. Query any concerns and explain problems or complications.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users