Click here to Skip to main content
15,894,189 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,
How to refere my c++ code in C#.net. Here i my C++ code

C#
#pragma once
using namespace System;
using namespace System::Windows::Forms;
namespace OpenDialogBoxVC {
    public ref class Form1
    {
        public:
            void OpenDialog(void)
            {
                System::Windows::Forms::OpenFileDialog^ OP = (gcnew System::Windows::Forms::OpenFileDialog());
                OP->ShowDialog();
            }
    };
}


I have right the solution and complied using VS2008. after compiling i did the below steps
1) Open new project and created WindowsApplication using vs2008.
2) Right click the reference and add reference of "OpenDialogBoxVC.dll"
3) added the below code in the WindowsApplication

MIDL
OpenDialogBoxVC.Form1 f = new OpenDialogBoxVC.Form1();
            f.OpenDialog();

4) while running the application, i am getting the error like

Could not load file or assembly 'OpenDialogBoxVC, Version=1.0.4155.21996, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.


Please help me
Posted

1 solution

Does your C++/CLI project P/Invoke any native code? Are all components the native code depends upon are available and visible through the file system (in executable directory or PATH)? This is the only reason I can see right now.

Try to use Microsoft Dependency Walker: http://en.wikipedia.org/wiki/Dependency_Walker[^], http://www.dependencywalker.com/[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900