Importing winform solution to mono (linux) from VS Code (windows) - c#

I tried to import a winform solution file from VS code (windows) to monodevelop (Linux) but it failed. The error is as follows:
Error while trying to load the project '/home/virtuall_kingg/Camera_GUI/Camera_GUI/Camera_GUI.csproj':
File not found: /home/virtuall_kingg/Camera_GUI/Camera_GUI/Camera_GUI.csproj
I added Camera_GUI.csprojfile also but still the error is same.
Can anybody guide me on how to import solution to mono?
This winform project has become pain in my neck.
Is building the GUI using gtk# in Ubuntu from scratch is the only way?

EDIT: Now you can substitute mono with .NET 5, the common .net framework for all platforms.
You are asking multiple questions here. In Linux you have (limited) support for WinForms through Mono. Depending on how complex is your project, you could port it without modification. If there are p/Invokes, then you won't for sure be able to port it.
Yep, in Linux the "other" big option is Gtk#, which has a long history. If you would want to port the project starting from scratch, it'd be a good option, but it'd involve porting your classes from working with WinForms to Gtk#, which is not impossible, but not trivial either. The feasibility of this would mainly depend on how good that project is architected. Do you have bussiness logic and views separated? If the answer is no, then the process will be tedious, and as hard as lengthy.
MonoDevelop is an IDE for C#, and Visual Studio for Mac is roughly MonoDevelop. It certainly works in Linux... as well as Visual Studio Code. So, there is no need to change anything in that front if you just need to port your code to Linux.
Okay, now, what's the road to follow? I think the best one is to try Mono with WinForms. It'd maybe involve simplify some code in the user interface part, but is certainly feasible. Just remember that you need to install Mono, and if your project is set to target .NET Core, then you need to create another project from scratch and set it to target .NET Framework.
Now, the specific question is that MonoDevelop complains about a missing Camera_GUI.csproj. This means that you've only picked a few files, but not the whole solution. Any IDE (Visual Studio, Visual Studio Code, Rider...), would complain about the same thing. Either remove the project from the solution, or add the project with all its files to the directory in which the solution sits.
So, the answer is: don't change anything if you don't need to retarget your project. Just move to a Linux box or virtual machine, with the whole project and open it in Visual Studio Code Rider, Rider, or MonoDevelop it does not matter. From within the IDE, remove those projects that make no sense in Linux (i.e., windows installer), and then recompile and start the program. Polish those parts of the user interface that need tweaking and that's it.
Should you need more help, please be more specific and provide more info.

Related

WPF .net Core 3.1 application deployment tools for any platform?

I have a utility editor application that goes with another main application. The main application is a Windows EXE usually, but there is also a Unix and a Mac version. This application was written by another company for us. It is not C#.
We have a utility editor program that works with the main application. The original version is a WinForms app, but it is showing it's age and some of the functionality no longer works on today's Windows. So the app is being rewritten in WPF with .NET Core 3.1, with the hope that maybe we will also compile it for Unix and Mac someday, if possible. They want it to be a stand-alone app so it can more easily be used by students at different universities and other organizations. Click-Once, MSIX, and copying larger folders are not options. They want a standalone EXE(s) they can upload/distribute for 32 and 64 bit Windows initially, often sent on DVD.
But I am having build issues for WPF. I have tried to publish the app, and the VS Installer add-on, but they were failures, which appears to be the common complaint on the internet. For some reason, you always end up with a DLL application instead of an EXE, and it doesn't run and I am not alone per the discussions on the internet. I am thinking is has something to do with the .NET Core but I just don't know enough about it to know how to resolve it. One article hinted that the DLL might be the portable part, and then you need a platform specific module that runs it??? Did I misunderstand that? If so, How do I create one?
I am now looking into third party tools. It appears Wix might be worth exploring, but the learning curve is billed as large, so the boss is nervous. I am also not sure about the Unix or Mac builds. Will those be different tools yet again?
According to this it probably is, but this is 2 years old:
How to build installers for .NET Core app?
Has anyone been successful in building a WPF .NET Core 3.1 setup.EXE that actually installs a usable application? If so, what tools did you use? Can you provide any advice for what I might be missing? I can get the setup.exe, but the app that it installs is not usable.
I would be ever so grateful for any help you can provide. This community has been SOOO helpful to me for many years and I can usually find the answer from previous questions without ever asking anything myself. So I have no rating. But I have been a user for over 10 years! Please don't hold that against me? But this time I am stumped. It could just be I am tooo new to .NET Core (first app in it) and I don't have the right search terms. I am usually a Web developer. But Web is not an option here.
Thank you for your consideration,
MLY
A bit late, you might have already figured out a solution, but for anyone else wondering.
One way is to use ClickOnce.
If using Visual Studios, you should be able to right click your main project and select "Publish". Then you should be able to click "New" publish profile. From the options that come up you can either select "ClickOnce", and then you should be presented with some settings. For you, most importantly, would be two of those tabs, "Install location" and "Configuration". In the former you can choose "From cd/dvd, or usb" since you mention that is a method of delivering the executable you will need.
And in the latter, you can select "Deployment mode" to be "self-contained", and under "File-publish options" choose "Produce single file".
This should ultimately produce an EXE for your application that can be used as a standalone.
Note that using VS19 there are some issues that seem to not allow this to happen https://github.com/dotnet/sdk/issues/11351
However using VS22 this does not seem to be an issue, I at least have not experienced it there.
For more information
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/app-development/deploying-a-wpf-application-wpf?view=netframeworkdesktop-4.8
https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2022
Also, F.Y.I, WPF applications only run on windows, so you wont be able to deploy them on Mac or Unix at all. There is some community support for using Xamarin.Forms with WPF, but if you need multi-OS deployment you should not start developing this application with WPF in the first place.

Developing with C# on OSX and Mono

I'm about to start a project that requires me to write c# code. The thing is, I've got a mac.
I was wondering if there are any pitfalls involved in c# development using mono on OSX 10.6
I think the page is clear that the implementation is crisp, but on the other hand I've read that people install VMWare or something like it to use Windows. I'd like to avoid that if possible.
Note
I'll be working on a team and all the
other guys have Windows machines
Thanks
Based on your comment to HiVoltRock's answer (ASP.NET development), I'd say Mono 2.10.1 and MonoDevelop will be just fine (the stable release of MonoDevelop works just fine, but for development on OS X I prefer to use the most recent version which I compile from Git).
There are some things to take into account, such as file paths (ie: if the windows devs are writing static paths such as ApplicationsInstallDirectory + "\data\templates\foo.bar"; you will run into problems as directory separators on Mac OS are forward slashes. Also if existing code is using P/Invoke or other specific Window's functionality you'll be in trouble.
Finally if your code base uses third party libraries that requires Windows this could cause you issues.
For reference our product has been designed since day one with a requirement that it runs on Mono on Linux or OS X. With that in mind we've made sure to consider everything with cross-platform execution in mind. If you're joining an existing product, the same considerations might not have been given, meaning a lot of the existing code isn't compatible with Mono.
The Mono Migration Analyser will help determine if you've got any incompatible code.
There is a bit of fud out there about developing under Mono. Our project is an MVC3 with Razor, running .NET 4 using NHibernate, StructureMap etc and there haven't been that many issues developing on a non-Windows machine.
Be aware that the .NET libraries from Microsoft and the implementations in Mono are compatible "most of the time." If you're working in a team, you may run into some headache related to these compatibility issues (also, if you're using any third party plugins to any .NET application you're writing, you may have issues as well.). If you didn't want to run a virtual machine, I'd just bootcamp into Windows. It might disrupt your flow if you're very used to the OSX UI, but if the rest of your team is using Windows, I'd do that just to avoid compatibility issues.
The biggest thing I've had developing on Mono (admittedly on Linux) was GUIs. The majority of GUI-less code will run just fine. The only thing I've had to do is catch a few different exceptions. GUIs, however, would be a whole different beast, so don't expect those to translate well at all.
I would highly recommend using windows thru vmware rather than trying to code with some unstable osx programs. It's not cool to code for hours on a mac and then realize that none of your code works on any windows machine or that the gui looks totally different than on your computer.Always choose the right tools and languages for the right problem. Besides, visual studio is pretty nice to work with most of the time.
I've come across odd cases of memory leaks and segfaults with code compiled on Windows and dropped onto a Mono Linbox as-is. I've also had issues compiling .csproj files with xbuild that had some MS quirk that xbuild wasn't familiar with.
If I'm not mistaken, the two compilers do slightly different things at times, which are related to subtle implementation differences in the runtimes. This is most likely the cause of the segfaults and memory leaks I've come across.
My bottom line is, compile on the same platform as the runtime. So for local testing, you should be fine (you compile on mono on your mac and run/test with mono on your mac). But don't build the project on your mac and then release the resulting Mono binaries to Windows servers running MS .NET runtime (or vice versa). If you have a build server best would be to stick to that (which we all should do anyway... right?).
If your team doesn't have a build process and you must build the binaries you are going to release, I would use a Windows VM for that final step.

Can anyone provide a good "idiot's guide" to creating an installer in VS2008 (C#) Pro?

I have Visual C# 2008 Professional and have developed the first half of a C# application (console mode) with the second half in progress now (GUI).
I'm looking for an easy path to creating an installer for it. What are the steps that need to be taken to produce a professional installer?
There's a similar question here regarding the Express edition but I have Pro, and I would like as much as possible to stick with just the standard VS stuff (if you think you can convince me that a third party installer creator is much better than a VS-only solution, give it a shot, by all means).
Keep in mind that I have no interest in upgrading to VS2010 yet, even if it's a hundred times easier to create an installer. That can come later, when the revenue starts rolling in :-)
Also be aware that the GUI component of this application is a totally separate executable from the console part. The console part is a simple "open file 1, do some work on it, write file 2" type and the GUI is a fairly standard "open file, do some stuff" beast so there's no tricky or wildly undocumented behaviour happening.
Basically, I'm looking for (at least) the following:
professional looking installer.
ability to specify where the application files go.
changes to the registry to allow double-clicks on my file extension to open the GUI app with the file as an argument.
needs to install everything required (my stuff, .Net if required, and so on).
This might be a bit more rant than answer but here it goes.
If there is one thing severely broken with Windows client software it is the deployment of applications.
My experience comes from working on NovaMind - Even though I have spent weeks over the years on setup issues, I am by no means an expert in setup technology and I try to focus on our actual product whenever possible. We have used InnoSetup, Visual Studio Setup Project 2008/2010 and finally we have switched to the WiX + Tools approach.
How do you install an application nowadays?
Web Apps: Enter a URL in a browser to get to a web app.
Mac: Drag the downloaded file (same for x64 and x86) to the Applications icon on the Mac. Done.
Windows: Download the right file (user needs to know about x64 and x86 architecture), execute it. Click ‘Next’ a dozen times, wait for the UAC to show, click yes and then hope that the installer did the right thing.
I think that if Windows had a better deployment system, a sane marketplace/app store and a proper live update feature, web apps might never have gotten that popular in the first place. Of course that’s an exaggeration but I believe a lot of damage has been done to the Windows applications ecosystem by not providing a sane, usable deployment model and even now Microsoft seems to pay very little attention to this problem.
How do you update applications nowadays?
Web Apps: No need. It is up to date.
Mac: No inbuilt magic but there is a widely used and powerful solution called Sparkle.
Windows: You better roll your own because there is nothing substantial out there.
ClickOnce should have changed all of this but failed to be usable for real commercial applications.
Here is the rundown:
InnoSetup and other script based installations are simple but cannot produce a .msi file — Some companies require .msi files to automate network deployments. You will also need to have a Windows Installer (.msi) based setup if you want to get the Windows Logo certification.
Visual Studio Setup Project 2008/2010 gives you the basics easily and you can configure a bunch of things but once you want to do the unthinkable like use a high quality icon or include a changing set of files into your setup, you’re screwed. We also had to manually fix the PackageCode and ProductCode every single time we built an update since Visual Studio managed to somehow mess up the assembly versions and would leave an older assembly when updating, thus corrupting the application.
WiX is the de-facto way to create setups on Windows and even the Microsoft Office Setup is supposedly created with WiX. WiX is not simple. There are books available for WiX!
Unfortunately, WiX alone is still not a good solution. We use the dotNetInstaller bootstrapper project to ensure the .NET Framework is installed and to wrap the .msi file and the bootstrapper into a single .exe file that people can download.
With all this you are mostly fine. There are always strange cases were customers don’t have the Windows Installer installed (and thus cannot run the embedded .msi file) or where the .NET Framework installation fails.
Things we haven’t been able to do so far:
Localizing our installer!
Providing a single download for both x64 and x86 — at the moment we only create a x86 installer because we don’t want our users to think about x64 vs. x86.
Have a nice setup UI that also works with high DPI settings. I think this might just be a thing that is not supported in MSI setup.
There is a free product called SharpSetup which seems to address some of these problems and allows you to write a Winforms based UI, but SharpSetup does not come with a bootstrapper and requires the .NET Framework — you can however write your own C++ code to react in this situation.
For live updates we have rolled our own solution and after many issues it is working okay.
You might also want to listen to Scott Hanselman’s podcast episode with Rick Brewster were they talk about the setup and deployment of Paint.NET — While I congratulate Rick and the Paint.NET team on their good setup, the necessity of such a complex solution saddens me.
If you absolutely need to use .msi then I would recommend WiX to anyone who wants to create an installer on Windows, but in the end I am extremely frustrated with the deployment situation on Windows. I have wasted weeks of my time over the years with silly setup issues. With setup you can only lose. You won’t win any happy customers because your setup works but you will lose and frustrate a lot of them if it doesn’t.
Another option is using Inno Setup. It allows you to fully customize installations, where to stick files on the target machine, modify the registry, and all that jazz. If you're willing to spend a bit more time learning a bit about the scripting required to achieve the results you want, it's a very powerful tool. (fulfills all of your requirements and much more) And most importantly, it's free =)
I've been using Inno Setup for all of my larger .NET programs. When the installer runs, it checks to see if .NET is installed and if not, downloads and installs it. As well, I've modified registry and made associations with extensions like you mentioned. Including DLL's with the installer is simple as well - Inno will lump all of the required files into a single executable that takes care of everything.
Additionally, since Inno has been around since 1997, a number of editors have arisen that help make the scripting process a lot easier.
I use Advanced Installer, it is dead simply, and I use it, because of the limitations of VS.
http://www.advancedinstaller.com/
The "downside" is that for fully automatic installation of dependencies you have to pay ;-)
If you want to create your installer fully in Visual Studio, but don't mind using external tools to help you in that job then have a look at a program of mine called SharpSetup. It allows you to build GUI using C#/WinForms, whereas backend is WiX based (which in turn means using WIndows Installer).
Visual Studio 2008 has built-in setup/installer support.
Add a new project to your solution, and select the 'Setup Project' option from the 'Other project types > Setup and Deployment' category.
Have a look at Windows Installer Deployment overview, and a step-by-step walkthrough
If you know scripting languages you can check out NSIS as an alternative to VS. There's enough documentation that you can copy paste their example installer and replace their file locations with your own.
While I'm not install expert, I've used Wix successfully. It's complicated to say the least.
I don't see any of these products being mentioned that I've seen clients use successfully.
http://www.installaware.com/
http://www.flexerasoftware.com/products/installshield.htm
http://www.wise.com/Products/Installations/WiseInstallationStudio.aspx
All provide localization, file/app for double click association, Framework bootstrapping and target location to the best of my knowledge. InstallAware and Wise provide some form of autoupdate support.

Anybody else using MonoDevelop?

I'm starting a new project in MonoDevelop, and I want to see how other projects are using it.
I tried searching through SourceForge, code.google.com, etc., but mostly I was just finding things like add ins or something related to MonoDevelop itself.
So is there anyone else using MonoDevelop, especially open source?
Basically, MonoDevelop is designed to function very similar to Visual Studio, including using all the same sln/proj file types. You can take a VS solution, open it in MD, and hit F5 to run it, and vice versa.
Because of this, I don't know that many people are going to write about "how they use MD as part of their project" any more than someone is going to write about how they use Notepad.
Any project that is using sln/proj files on Linux/Mac is likely using MD.
MonoDevelop is multiplatform IDE, especially for Linux. Works with Visual Studio solution and project files (100% both direction compatibility). So you can't find project using it. Any C#/VB.NET project can be developed in MD.
Three years ago me and a friend started work a new mono project and tried to use MonoDevelop for it. However - this was an impossible mission - we got ridden with all kinds of bugs and crashes and in the end I said - go to hell MonoDevelop - I'll use my tried and true Emacs.
To tell you the truth with no features other than formatting and font locking Emacs turned out to be 10 times more productive environment for me. My friend somehow endured using MonoDevelop for the whole run of the project, but afterwards he said he was done with Linux for good if it offered such low quality dev tools.
Times were different back then, I've been following mono's development and monodevelop's as well - they seem to be turning out quite well. I think that the actual cause of your problem - not finding anything - lies in the fact that most Linux devs openly shun Mono as a development platform because of it's Microsoft roots. This is sad - because it's a solid alternative of Java - especially at the desktop applications front(GTK# is seriously cool).
Banshee seems to be using MonoDevelop. Probably most of the prominent mono projects with a GUI use it as well to some extent.
I've found MonoDevelop to be excellent so far. I've only been using it for about a month, but once I got it set-up the way I want it, I wouldn't go back to any other editor or IDE on Linux. It took me a while to figure out how to set the debugger up and configure the editor to how I like it.
It's almost like having Visual C# Express on Linux.
Try searching for MonoTouch projects. Mac + MonoDevelop + .NET iPhone apps.
I just tried compiling my project, 2 problems:
couldn't load Setup projects
couldn't load SQL Server Library projects
There is a way around this of course, just have to consider that not all project types can be built in mono and must design solution the way it doesn't stop you from building what you want.

Deploying C# (.NET 2.0) application as a portable application?

Is it possible to deploy a .NET 2.0 application as a portable executable?
So that my program can be ran in a Flash Disk without the .NET Framework 2.0 installed in the target machine. Or maybe is it possible to distribute my program with the required .NET DLLs, so that no framework installation is necessary?
I know that there are some alternative tools to turn my .NET exe into a single native executable like RemoteSoft Salamander, Xenocode Postbuild, and Thinstall, but unfortunately I can't afford one.
I also tried to embed the dependencies with Mono's mkbundle, but it messed my program up =\ (no XP visual style, broke some controls and its functionality)
Any kind of help would be appreciated :)
Thanks.
fyi: my IDE is Microsoft Visual C# 2008 Express Edition with .NET Framework 2.0 as the target framework.
Well, other than things like Salamander and Thinstall (now VMWare ThinApp) you would have to have .NET installed if you really want to run .NET.
It may be possible to run Mono without actually installing it (not statically linking your program, but including Mono on the flash drive). I suspect it would be tricky though, as you'd have to tell the runtime about things like the GAC location.
I can't see anything in the Mono FAQ about this, but you might want to ping a Mono mailing list - it sounds like a potentially interesting and useful thing to be able to do.
No; you need either the framework installed, or the tools like you have mentioned.
You could potentially look at mono's new static linker, but that is about it...
I have not tried this myself but here's the procedure:
Make a C# project.
In Solution Explorer, inside your project, there is a line "Reference". Click the plus near it. Now you can see all the dependencies of your project. Delete all references that aren't used (delete, and try to run/build. If it is possible to do it, that it is unused. If there is an error, return it by adding it (right mouse click, "Add Reference")).
For each reference, go to Properties, and in the property "Copy Local" choose "True". For each Image, Icon... make like to the referenced.
Rebuild you project. Now in your Build/Release folder (inside bin) you will see many dll files. Those files have the information of every resource.
Copy all the files in the folder (from step number 4) into a new folder.
Go to the folder: "\Microsoft.Net\Framework\" and copy the file "mscrolib.dll" to the new folder from step 5. If you don't find this file, you can always make a search in the Hard Drive which contains Windows folder.
Now your app is portable (with the whole folder content).
-- Source: http://www.codeproject.com/Tips/392308/Csharp-Portable-Exe-File
Well Thinstall is very expensive and it doesn't work in all situations. If you want to run your app without .Net installed you might run into trouble although there are tools that do that Xenocode has a tool that can do this for you and it's cheaper than thinstall.
But if you ask my opinion it's a bad idea to use them. Better convince your target market to install .Net 2 (Which is pretty much universal these days), and then pack all of your library files into one file using a cheaper Obfuscator like tool (There's a good one from Smartassembly.)
I've used Thinstall for a long time, and I've worked on this technology a lot, so I am not shooting off without experience.

Categories

Resources