Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:14:50+00:00 2026-06-13T04:14:50+00:00

I have a C# / Mono / Gtk# program that simply loads files dropped

  • 0

I have a C# / Mono / Gtk# program that simply loads files dropped in the window as Gdk.Pixbuf and displays them.

It works well on Ubuntu. But on Windows if I try to drop a file with a non-ASCII filename such as C:\áéíóú.jpg, the program will crash. I thought it was a problem with my code first. So I did a simple testcase.

Console.WriteLine("{0} exists? {1}", Filename, File.Exists(Filename));
Pixbuf pixels = new Pixbuf (Filename)

Output

C:\áéíóú.jpg exists? True
GLib.GException: Failed to open file ‘C:\áéíóú.jpg’: No such file or directory

As it turns out, Glib can’t figure out a file that exists, exists. And I don’t know how to fix it so that I can load an image file into Pixbuf on windows from a Unicode filename.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:14:51+00:00Added an answer on June 13, 2026 at 4:14 am

    This seems to be a problem in the gtk-sharp<->gdk-pixbuf interoperation.

    Apparently on every OS except windows, gdk_pixbuf_new_from_file takes file name encoded in utf8. On windows, however, this function is renamed to gdk_pixbuf_new_from_file_utf8 and replaced by a wrapper that does locale conversion and proceeds to call the utf8 version. gtk-sharp doesn’t know this and uses gdk_pixbuf_new_from_file passing utf8 argument, hence the unexpected extra locale conversion on windows breaks the filename.

    As a workaround I have suggested to use the Pixbuf constructor that takes a Stream instead of a filename, but the poster has reported that doesn’t load his image properly.

    Update:
    Luckily the Pixbuf wrapper class has a constructor that accepts the raw IntPtr of an existing pixbuf object. As such, the code in the buggy constructor can be duplicated, fixed and hidden in some helper methods, such as:

    [DllImport("libgdk_pixbuf-2.0-0.dll")]
    static extern IntPtr gdk_pixbuf_new_from_file_utf8(IntPtr filename, out IntPtr error);
    
    static Pixbuf CreatePixbufWin32(string filename)
    {
        IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup(filename);
        IntPtr error = IntPtr.Zero;
        IntPtr raw = gdk_pixbuf_new_from_file_utf8(native_filename, out error);
        GLib.Marshaller.Free(native_filename);
        if (error != IntPtr.Zero) throw new GLib.GException(error);
        return new Pixbuf(raw);
    }
    
    static Pixbuf CreatePixbuf(string filename)
    {
        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
        {
            return CreatePixbufWin32(filename);
        }
        return new Pixbuf(filename);
    }
    

    I have tested this with success. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Environment: Mono 2.6.7 CentOS 5.4, 32-bit I have a Gtk Window with various docking
I have installed Mono 2.10.8 (that should have .NET 4 support) and MonoDevelop 2.8.6.4
We have a team that built an agent in Mono using MonoDevelop on Mac
I have recently discovered that I am affected by this bug http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71515.html Well, at
I seem to have a Mono problem that I cannot duplicate in my Windows
in other words, now that we have Mono, has C# become just as OS-agnostic
We have a Mono application under Linux that does image processing on a bunch
I am working on a Mono GTK# desktop app written in C#. I have
We're thinking about moving over to Mono and I see that Dapper works with
Is it possible to install Mono and Gtk on a Windows computer, copy that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.