I am attempting to deploy a simple f# console app to a coworkers computer but it keeps failing. After double clicking on the app icon, the console window appears but then the Microsoft error reporting window shows up asking if I would like to send the error report, I decline then some text flashes in the console window. It looks like an error message, but the window closes too fast to tell. The weird thing is, if I create a similar C# app, it works. I am targeting .net 4 client framework in release mode.
Here is the code
f# code (doesn't work):
open System
printfn "print test"
Console.ReadLine() |> ignore
c# code (does work):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestCApplication
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Testing...");
Console.ReadLine();
}
}
}
The F# analog of your C# snippet would be not your F# code, but the following:
System.Console.WriteLine "print test"
System.Console.ReadLine() |> ignore
While the app off 2-liner above will run, similarly to one off your C# snippet, just on raw .NET, use of printfn function in your F# code requires certain F#-specific core components being deployed on the target computer, which is likely not the case. The latter explains the observed behavior.
Look at the references of your F# project and you will see one to FSharp.Core which is normally located here:
C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\FSharp.Core.dll
On Windows 7 (64 bit) PC
Also look at the F# site to get the runtime download.
http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/release.aspx
EDIT: here is the direct link to the runtime download (thanks ildjarn):
http://www.microsoft.com/en-us/download/details.aspx?id=13450
Related
Whenever I attempt to run C# in VS Code, the program asks for the environment. When I pick ".NET 5+ and .NET core" all that happens is a settings.json file gets opened up as another tab. The second environment option is ".NET Framework 4.x (Windows Only)" all that happens then is that a flash of the code running bar pops up.
However it can run Java, but I do not want to do Java. It could be an user error, I wouldn't be surprised if I just couldn't find how to run code.
The problem is that the code runs and exits immediately
You should add Console.ReadKey() at the end of the Main method like this:
using System;
class Program
{
static void Main(string[] args)
{
// Your Code here
Console.ReadKey(); // At the end of the Main method
}
}
I am about to start development of a software project that should run on Linux and Windows if possible. As I already have some experience with C# I am eager to use it for this project. I assumed that with .NET Core 3 and GTK# 3.22 this shouldn't be a problem since .NET Core App should be cross-platform out of the box. GTK# - from my understanding - should work everywhere GTK+ in the same version is also available.
Why c#? Well I just like the language and there is an ECS Framework for c# I'd like to use.
So far I have setup a test Console App project in Visual Studio targeting .NET Core 3 and added an GTK# specific NuGet package.
I wrote a simple Hello World program for testing of the environment.
using System;
using Gtk;
namespace GTKTest
{
class Program
{
static void Main(string[] args)
{
Application.Init();
Window win = new Window("Hello GTK");
Label lbl = new Label("This is a test GTK App written with C# for GNU/Linux and Windows");
win.DeleteEvent += Win_DeleteEvent;
win.Add(lbl);
win.ShowAll();
Application.Run();
win.Dispose();
Console.Write("Press any key...");
Console.ReadKey();
}
private static void Win_DeleteEvent(object o, DeleteEventArgs args)
{
Application.Quit();
args.RetVal = true;
}
}
}
When I run this code from Visual Studio 2019 I get
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Gtk.Application' threw an exception.
Source=GtkSharp
StackTrace:
at Gtk.Application.Init()
at GTKTest.Program.Main(String[] args) in D:\Workspace\VSRepos\C#\GTKTest\Program.cs:line 10
Inner Exception 1:
DllNotFoundException: Gtk
While searching for a solution I installed mono and GTK# for Windows from this page. The mono part shouldn't be necessary if I stick to .NET Core I think.
What am I missing? What am I doing wrong? Is what I'm trying to achieve even possible like I am imaging it? I'm also interested in some alternatives how to program cross-platform GUI-Software with C#. I stumbled upon electron.js but I heard it has some big Memory overhead and I'm not really into javascript. AvaloniaUI sounded interesting but I thought that the above approach would be better.
Edit: After adding msys path like suggested here in step 3 I get following error preceding the exception from above. The error states that the procedure entry point couldn't be found in the dll.
I know this is an old question, yet Google likes it.
I have had the similar problem. There are lots of guides that are easy to google but hard to make them work. Here is the guide that helped me as of April 2022:
Step 1: Install MSYS2
Download the MSYS2 installer and follow the installation instructions.
Step 2: Install GTK+3 Open a MSYS2 shell, and run: pacman -S mingw-w64-x86_64-gtk3
Step 3: Modify PATH variable so that the library can be found
Open up Control Panel
Go to System and Security > System
Click on the Advanced system settings link
Click on Environment Variables... button
Under System variables find the Path variable and select it
Click the Edit button
Add either ;C:\msys64\mingw64\bin or ;C:\msys32\mingw32\bin to the end of the variable, depending on your system architecture
Click OK, and you are done
Restart your system for the changes to apply
To run GtkSharp Samples project you would also need:
pacman -S mingw-w64-x86_64-gtksourceview4
Otherwise it throws ...System.DllNotFoundException: GtkSource: libgtksourceview-4-0.dll...
Then you may either install GtkSharp from here or from nuget.
EDIT: I have edited the whole question, since this is not only for Unity3D, but at all .sln projects.
I have a installation of Visual Studio Code(Not Visual Studio, but this:https://code.visualstudio.com/) on my Macbook at work. VSCode is otherwise working just fine with normal and Unity3D projects. I get Intellisense on all classes, including Unity3D specific ones, like GameObject. So I think my installation and startup sequence is correct.
Only problem I have, is that VSCode does not seem to recognize constants defined in the .csproj files. First I noticed this with some Unity3D plugins, but it is persistent on normal Visual Studio projects too.
My sample project is a dummy application downloaded from internet, but it is fully working on MonoDevelop. This is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DummyConsoleApplication
{
class Program
{
static void Main(string[] args)
{
tester();
}
#if DEBUG
static void tester(){
}
#endif
}
}
The function call in Main causes a not found exception on the editor, but it compiles fine, since the .csproj file has this line:
<DefineConstants>DEBUG;TRACE</DefineConstants>
Any verification on if this is normal behaviour for VSCode would be greately appreciated. Also, if anyone is aware of any solution, even hacky ones, to get past this bug and force Intellisense to autocomplete would help out too.
The error I get is:
The name 'tester' does not exist in the current context [DummyConsoleApplication]
My hardware is a Macbook with Yosemite and my compiler is dnx-mono.1.0.0-beta4.
This is a known limitation with OmniSharp, the C# engine that Visual Studio Code is built around. There is an open enhancement request for adding <DefineConstants> support, but it is tied to a larger issue with regards to MSBuild Support.
Currently, this isn't a supported configuration under Visual Studio Code. You can try to define your constants through the launch.json instead, but support is minimal at best.
It should work...
As a sanity check, have you:
"Sync MonoDevelop Project" recently?
Make sure Visual Studio Code has the -csharp solution (.sln) selected? (Click the flame in the status bar to change)
Sheepishly looking for a short step-by-step guide on taking a single .cs file like:
using System
namespace Simple
{
class Program // declare a class
{
static void Main()
{
Console.WriteLine ("Hi there!");
}
}
}
and be able to compile and run it in Xamarin Studio (version 5.5.1, build 15) on the Mac (Mono SDK is already installed). I am not interested (yet!) in anything complex like developing an app or anything, but just a way to practice learning C#. I do know how to compile and run using Terminal, but can't seem to figure out how to compile/run a simple .cs file from XS. Thanks :) Hopefully my participation here at SO will be a bit more sophisticated in the future :)
I'm assuming you have created a solution and project in Xamarin Studio? There is a run button in the interface (looks like play on a remote). If you created your .cs file outside Xamarin, you'll probably have to import it into the solution by right clicking the project and clicking add files. I'm pretty sure you can also open a .cs in Xamarin without it having any solution/project attachments. Again, you should be able to hit the play button.
If you haven't got yourself a solution, fire up Xamarin to the welcome page and click new solution. You should have the option to choose C# console project (or even an empty project if you want to start from scratch) or something similar (I'm fuzzy on the details: I typically use MonoDevelop and my copy of Xamarin is buggy right now). Fill out the forms and voilĂ ! A "hello world!" file should be there.
Hope this helps!
I have an application that works fine in Visual Studios 2008, and I am trying to get it into VS 2010 in order to use .NET 4, and I have a really weird problem. When I run the code from either Release mode or Debug mode with the debugger attached (F5), I have no problems running the program. However, when I run the program from either Release or Debug without the debugger attached (Shift+F5), I get an Access Violation Exception when I attempt to run some code in a dll from GDCM. I've created the dlls by using CMake and Swig and following the instructions here adjusting the instructions where necessary to build for VS 2010 and .NET 4.
Does any one have any ideas why this is happening and how I can fix it?
Here's an example of a program where the error occurs. Again, if you create a project with the following as the program in VS 2010 it will run fine when the debugger is attached and fail if the debugger is not attached.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using gdcm;
namespace GDCMVS2010Test
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("This program prints the patient name of a dicom file with gdcm");
Console.WriteLine("Usage: [input.dcm]");
return;
}
gdcm.Reader reader = new gdcm.Reader();
reader.SetFileName(args[0]);
reader.Read();
gdcm.File file = reader.GetFile();
gdcm.StringFilter filter = new gdcm.StringFilter();
filter.SetFile(file);
string value = filter.ToString(new gdcm.Tag(0x0010, 0x0010));
Console.WriteLine("Patient Name: " + value);
}
}
}
You should really start using GDCM specific groups to communicate your issues, see:
http://sourceforge.net/apps/mediawiki/gdcm/index.php?title=General_questions#Where_are_the_GDCM_mailing_lists_.3F
100 of GDCM users are on this list and will be able to help you.
You should also provide a dataset (the DICOM file) to help with reproducing the bug.
Thanks
The client profile misses out chunks of the .Net framework that you are unlikely to need on a client machine. ASP .Net for example. See this link http://msdn.microsoft.com/en-us/library/cc656912.aspx
This was because the version of SWIG I was using wasn't working correctly. A new version of SWIG was recently released (version 2.0) which solves this problem. After I reran CMake on GDCM, and then rebuilt GDCM with VS 2010, and put the GDCM dlls back into my example code, everything worked fine.
Check your project properties. I have encountered this problem when I had my Target Framework set to .NET Framework 4.0 Client Profile, when it should have been the one w/out Client Profile. Or vice versa.