mono gtk# - hello world deploy to windows - windows

I have this really simple Hello World example i wrote on a linux host using Mono and gtk#. It simply shows a windows with a button. Now i tried to get the binary running on windows but failed. i installed the gtk# with the standalone installer from the mono homepage. when i start the application it failes due to:
System.DllNotFoundException was unhandled: Unable to load DLL
'libglib-2.0-0.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E) Source=glib-sharp
Any suggestions?
BR

You need either to run your app via mono.exe or just add the mono.exe location to the PATH environment variable value. You can do that in run-time like that:
[STAThread]
public static void Main(string[] args)
{
var dllDirectory = #"C:\Program Files (x86)\Mono\bin";
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory);
Run();
}
private static void Run()
{
Gtk.Application.Init();
Forms.Init();
var app = new App();
var window = new FormsWindow();
window.LoadApplication(app);
window.SetApplicationTitle("Game of Life");
window.Show();
Gtk.Application.Run();
}

You will have to register the DLL 'libglib-2.0-0.dll' in Windows using regsvr32 libglib-2.0-0.dll from the command prompt. An alternative is to just package all the dependencies with your executable.
Hope this was helpful.
-Dave

Related

Use shared library created with Matlab Compiler SDK in OMNeT++ simulation

I am trying to call Matlab Functions from my OMNeT simulation. Therefore I created a shared library using the mwArray API. However, when I try to run the sample code, the simulation terminates with the following error message:
Error in final launch sequence:
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program exited with code 0xc0000135.
Failed to execute MI command:
-exec-run
Error message from debugger back end:
During startup program exited with code 0xc0000135.
During startup program exited with code 0xc0000135.
Did anyone else encounter the same problem?
I am using OMNeT 5.6.2 and Matlab 2020a under Windows
The code for my module is
#include <omnetpp.h>
#include "compilerTest.h"
using namespace omnetpp;
class ExampleModule : public cSimpleModule
{
protected:
simtime_t timerInterval;
cMessage * timer;
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
Define_Module(ExampleModule);
void ExampleModule::initialize()
{
timerInterval = 1.0;
timer = new cMessage("timer");
scheduleAt(simTime() + timerInterval, timer);
}
void ExampleModule::handleMessage(cMessage *msg)
{
if (msg->isSelfMessage()){
bool x = mclInitializeApplication(NULL, 0);
scheduleAt(simTime() + timerInterval, timer);
}
}
The message indicates that the error occurred during the startup of the process. It means that the process probably cannot load the Matlab runtime DLL. The directories where the Matlab DLLs reside must be present on the system path so the operating system can load them. On Windows it is especially hard to avoid DLL hell and fix these issues (mostly because of the lack of proper error messages). First, I would try to start the example from the MinGW env command prompt where you can control the PATH manually and try to run from the IDE only after it works in the command line.

UnsatisfiedLinkError when using flink-s3-fs-hadoop

I have experience UnsatisfiedLinkError when I tried to use
flink-s3-fs-hadoop to sink to s3 in my local Windows machine.
I googled and tried several solutions like download hadoop.dll and
winutils.exe, set up HADOOP_HOME and PATH environment variables, copy hadoop.dll to C:\Windows\System32, but none of them worked.
I also tried to load the hadoop library myself in the code by using
System.loadlibrary("hadoop"), it succeed, but the error still happen,
anything additional step I am missing?
Here is my code (the 2nd and 3rd line is just trying to debug and it will succeed on the 2nd line but throw the UnSatisfiedLink exception in 3rd line):
public static void main(String[] args) throws Exception {
System.loadLibrary("hadoop");
NativeIO.Windows.access(null, NativeIO.Windows.AccessRight.ACCESS_READ);
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
DataStream<String> ds = env.readTextFile("s3://fts-test/test/input.csv");
ds.print();
ds.writeAsText("s3://fts-test/test/output.csv");
env.execute();
}
By the way I am using Window 7 64 bit, flink 1.5.

Operation not permitted on IsolatedStorageFileStream. when using MvvmCross file plugin

I have an instance of IMvxFileStore implementation for for Windows Phone injected into my service.
Let say I want to store settings in a file located at appsettings\userprofiles\profile1.txt
Using the file plugin, I first call the API EnsureFolder exists, passing in the full path to my profile settings file appsettings\userprofiles\profile1.txt to ensure that this folder has been created and does exist.
Just for sanity, I check to ensure that the folder has been created using the FolderExist API. This always returns true atleast for now.
The code looks like this:
private string GetStorageItemFileName(string filename)
{
Guard.ThrowIfNull(string.IsNullOrWhiteSpace(BaseDirectory), Messages.RepositorBackingStoreIsNull);
filename = _fileStore.PathCombine(BaseDirectory, filename);
_fileStore.EnsureFolderExists(filename);
if (_fileStore.FolderExists(filename))
{
// what do do????
}
return filename;
}
However, when I attempt to write content to the file using WriteToFile API, passing in the file name returned from the method above and some string, as follows
try
{
_fileStore.WriteFile(filename, content);
}
catch (Exception ex)
{
Logger.Error(ex);
}
, I get the following exception:
System.IO.IsolatedStorage.IsolatedStorageException was caught
HResult=-2146233264 Message=Operation not permitted on
IsolatedStorageFileStream. Source=mscorlib StackTrace:
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path,
FileMode mode, FileAccess access, FileShare share, Int32 bufferSize,
IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path,
FileMode mode, IsolatedStorageFile isf)
at Cirrious.MvvmCross.Plugins.File.WindowsPhone.MvxIsolatedStorageFileStore.WriteFileCommon(String
path, Action`1 streamAction)
at Cirrious.MvvmCross.Plugins.File.WindowsPhone.MvxIsolatedStorageFileStore.WriteFile(String
path, String contents)
at TrackuTransit.Core.Services.DataStore.StorageItemFileRepository.Put(String
filename, StorageItem data) InnerException:
My dev environment is setup as follows:
- Surface Pro 3
- Visual Studio 2013 Community
- Windows Phone 8.1 SDK and Simulator
- MvvmCross 3.0.0.4. (yes,, it is old and will be updated after MVP).
Before I go digging into the MvvmCross code base, anyone with ideas on what I could be doing wrong here?
Upgraded the project to .NET 4.5 and also upgraded to MvvmCross 3.5.1 and still ran into the same problem. Although I lost a couple of days due from the upgrade, I am glad it is over with.
The problem I am running into here has to do with the fact that I am calling
_fileStore.EnsureFolderExists(filename);
and passing in the full path to the file. Underneath the scenes, MvvmCross is calling
IsolatedStorageFile.CreateDirectory(filename);
which appears to be creating a directory with the same file name. So passing in "images\image1.png" to the above API appears to create a directory or hold some IO resource related to "images\images.png".
When you attempt to write to file using
_fileStore.WriteFile(filename, content);
MvvmCross is attempting to create a file stream using
var fileStream = new IsolatedStorageFileStream(path, FileMode.Create, isf))
and the exception is thrown right here.
Fix is to ensure you are passing to IMvxFileStore.EnsureFolderExists API just the folder in question. In this case it is "images". Then you pass to IMvxFileStore.WriteFile the relative path to the file including the file name such as "images\image1.png" and you are good to go.
Fixed code looks like this:
private string GetStorageItemFileName(string filename)
{
Guard.ThrowIfNull(string.IsNullOrWhiteSpace(BaseDirectory), Messages.RepositorBackingStoreIsNull);
filename = _fileStore.PathCombine(BaseDirectory, filename);
// assumption is that filename does not contain directory information
_fileStore.EnsureFolderExists(BaseDirectory);
return filename;
}

How can I get Microsoft's AppFabric 1.1 installed on Windows Server 2012 OS?

I have been attempting to install AppFabric 1.1 on a machine with Windows Server 2012 OS using this download WindowsServerAppFabricSetup_x64.exe from here:
While attempting this I've ran into all kinds of issues. These are the steps I've taken so far, and each step has seemed to get me closer, but I'm still not there yet.
Make sure the Windows Update service is up and running before attempting the install.
Ensure that there is not a problem with the PSModule Environment variable. I've seen a few posts related to this issue, and the easiest solution (but maybe not the best) that I've found is to delete the environment variable altogether. For a reference look at Lucas Massena's post on July 13 2012 found here -> social.msdn.microsoft.com/Forums/en-US/velocity/thread/561f3ad4-14ef-4d26-b79a-bef8e1376d64/
Create a config folder inside "C:\Windows\SysWOW64\inetsrv\" . This seemed like a bizarre work around, but seemed to fix one of the issues I was running into. - Seemed to fix this --> Error: c:\Windows\SysWOW64\inetsrv\config: The system cannot find the file specified.
Reference to post.
Now I'm running into this error:
EXEPATH=c:\Program Files\AppFabric 1.1 for Windows Server\ase40gc.exe PARAMS=/i administration
[RunInstaller]
Output: Attempt 1 of 3: SuppressErrors=False
Output: [Initialize]
Output: Info: Initializing for update to administration.config...
Output: Installer **ERROR: 0x80040154 Class not registered**
Output: (Waiting 5 seconds)
Output: Attempt 2 of 3: SuppressErrors=False
Output: [Initialize]
Output: Info: Initializing for update to administration.config...
Output: Installer **ERROR: 0x80040154 Class not registered**
Output: (Waiting 10 seconds)
Output: Attempt 3 of 3: SuppressErrors=False
Output: [Initialize]
Output: Info: Initializing for update to administration.config...
Output: Installer ERROR: 0x80040154 Class not registered
Output: **ERROR: _com_error: 0x80040154**
Output: Exit code: 0x80040154 Class not registered
Does anyone know what this executable "c:\Program Files\AppFabric 1.1 for Windows Server\ ase40gc.exe" is doing that is causing this "Class not registered" error? And if so, what steps I can take to fix it??
Please help!
Thanks
I discovered that I needed to enable some .NET Framework features. Once I did this, the AppFabric install successfully completed.
To enable the needed .NET Framework features you can run these commands from PowerShell:
Import-Module ServerManager
Add-WindowsFeature -Name AS-NET-Framework
Add-WindowsFeature -Name WAS-NET-Environment
Since I am installing AppFabric as a prerequisite for another install I wrote this C# script to run the powershell commands on server 2012 (so users won't have to):
using System;
using System.Diagnostics;
namespace ServerManagerFeatures
{
class Program
{
private static ProcessStartInfo startInfo = new ProcessStartInfo();
private static Process process = new Process();
public static void Main(string[] args)
{
try
{
startInfo.FileName = "powershell.exe";
startInfo.Arguments = "Import-Module ServerManager;"
startInfo.Arguments += "echo 'Enabling .NET Framework 4.5'; Add-WindowsFeature AS-NET-Framework;";
startInfo.Arguments += "echo 'Installing .NET Framework 3.5 Environment. This may take several minutes. Please be patient.'; Add-WindowsFeature WAS-NET-Environment; ";
startInfo.UseShellExecute = true;
process.StartInfo = startInfo;
process.Start();
process.PriorityBoostEnabled = true;
process.WaitForExit();
}
catch (Exception e)
{
MessageBox.Show("Error:" + e.Message + " Make sure you have powershell installed and the executable path is stored in the PATH environment variable.");
}
}
}

Does VS 2008 or 2010 Express edition come with any kind of usable from console http downloading util?

I want to create a simple project setup script. I assume user (which owns a PC with VS2008 or 2010 on board (Express)) can download a .BAT file with my set up script from the internet. I wonder is there any standart utill that comes with VS that would be capable to download needed for my project setup source and project files via http on some commatnd call in BAT file (which is ran from VS consol)?
nope. I suppose you should get somewhere
doing a 6-line C# program, e.g. to download prime numbers to 100k:
using System;
using System.Net;
using System.Linq;
class MainClass
{
public static void Main (string[] args)
{
using (var wc = new WebClient())
foreach (Uri url in args.Select(a => new Uri(a)))
wc.DownloadFile(url.ToString(), url.Segments.LastOrDefault()?? "unnamed");
}
}
Compile: csc.exe Downloader.cs; voilĂ , minimalist wget.net (on Mono, use gmcs.exe Downloader.cs. Both executables will run on Mono on Linux, Solaris and MacOs just as well.
Call it with e.g. Downloader.exe "http://www.mathsisfun.com/includes/primes-to-100k.zip" "http://www.mathsisfun.com/includes/primes-to-200k.zip" ...
TODO: error handling
using NuGet (download the standalone .exe)
using PowerShell (install the MSI; this does a lot more)
My recommendation is to install some kind of UNIX shell + userland subset. Weapon of choice: Cygwin (http://cygwin.com), but several others exist (UnxUtils, MingW ports and dozens others)
Google for wget.exe + windows and you shall find them
HTH

Resources