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

  • Home
  • SEARCH
  • 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 7073377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:55:20+00:00 2026-05-28T05:55:20+00:00

[DllImport(Project1.dll)] unsafe static extern void CallFu(string OpenFile, string SaveFile); This is dll on C++

  • 0
[DllImport("Project1.dll")]
unsafe static extern void CallFu(string OpenFile, string SaveFile);

This is dll on C++
The Function get image file string do smth and save new image to SaveFile string.

extern "C" void __export __stdcall CallFu(char* filepath,char* savefilepath) 

Then i try to put saved image to ImageControl

string save = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\segmentedKletka.bmp";
private void B_AutoSegm_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        string open = MainWindow.OsnovnoyClassPict.Pict_Source;
        CallFu(open, save);

        BitmapImage s_bmp = new BitmapImage(new Uri(save));

        Slider_Kletka.Maximum = Slider_Yadro.Maximum = s_bmp.Width;
        Slider_Kletka.Value = Slider_Yadro.Value = s_bmp.Width / 2;
        Slider_Kletka.IsEnabled = Slider_Yadro.IsEnabled = true;

        Img_Kletka.Source = Img_Yadro.Source = s_bmp;

                }

and here i get the error

An unhandled exception of type ‘System.ArithmeticException’ occurred in mscorlib.dll
Additional information: Переполнение или потеря точности в арифметической операции. (Overflow or underflow in the arithmetic operation.)

How use c++ dll in WPF correctly?

        [DllImport("Project1.dll")]
        unsafe static extern void CallFu(string OpenFile, string SaveFile);
        public Form1()
        {
            InitializeComponent();
            string open = "D:\\SPPR_Gem\\SPPRGem\\bin\\Release\\kletki\\1a2a917d-45379cc5-451b3e95-a20e772c.bmp";
            string save = "D:\\Projects\\SPPRGem\\SPPRGem\\bin\\Release\\segmentedKletka.bmp";
            CallFu(open, save);
            pictureBox1.Image = new Bitmap(save);
        }

This is in c# only. And i have no errors.

P.S. sorry for my bad english =)

  • 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-05-28T05:55:21+00:00Added an answer on May 28, 2026 at 5:55 am

    Solution
    http://social.msdn.microsoft.com/forums/en-US/wpf/thread/a31f9c7a-0e15-4a09-a544-bec07f0f152c

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

Sidebar

Related Questions

I was using GetWindowLong like this: [DllImport(user32.dll)] private static extern IntPtr GetWindowLong(IntPtr hWnd, int
i have a method registered like this: [DllImport(MyApi.dll, CharSet = CharSet.Ansi)] private static extern
I call C++ function from C# project: [System.Runtime.InteropServices.DllImport(C.dll)] public static extern int FillSlist(out string
[DllImport(user32.dll)] public static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); [DllImport(user32.dll,
I'm calling the following from c#: [DllImport(u3dapi10.dll, CharSet=CharSet.Auto)] public static extern uint dapiCreateSession(out uint
Platform Invokation in .NET Framework available on Windows. [DllImport(user32.dll, CharSet=CharSet.Auto)] public static extern MessageBoxResult
I have created a minidump using win32 api [DllImport(DbgHelp.dll, SetLastError = true)] private static
My Project1 is here \Project1\Bin\Debug\application.exe and my dlls are in \Project1\Debug\3rdparty.dll How to get
For example, if I'm declaring: internal static class WinAPI { [DllImport(DwmApi.dll, PreserveSig = false)]
I've import dll in my code like that: [DllImport(dll.dll, CharSet = CharSet.Ansi)] private static

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.