473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Adding MFC dll to C# application

5
Hi,

In case I want to use a MFC dll to my C# application.
Can I just add it as a refernce to the project and use it, or do I need to add something else.
I saw some examples with Assembly.LoadFile|("something.dll") - when it is used?


Thanks
Idit
Jan 26 '07 #1
3 6315
Motoma
3,237 Expert 2GB
Hi,

In case I want to use a MFC dll to my C# application.
Can I just add it as a refernce to the project and use it, or do I need to add something else.
I saw some examples with Assembly.LoadFile|("something.dll") - when it is used?


Thanks
Idit
Adding the DLL to the References should be enough.
Another way to do it, (albeit the hard way), is to use DllImport. For example, if you wanted to use the IsWindowVisible() call from user32.dll, the resulting code would look like:
Expand|Select|Wrap|Line Numbers
  1.   [DllImport("user32.dll", CharSet = CharSet.Auto)]
  2.   public extern static int IsWindowVisible(IntPtr hWnd);
  3.  
  4.   // And later in the code you would call it normally
  5.  
  6.   IsWindowVisible(hWnd);
  7.  
Jan 26 '07 #2
Idit
5
Adding the DLL to the References should be enough.
Another way to do it, (albeit the hard way), is to use DllImport. For example, if you wanted to use the IsWindowVisible() call from user32.dll, the resulting code would look like:
Expand|Select|Wrap|Line Numbers
  1.   [DllImport("user32.dll", CharSet = CharSet.Auto)]
  2.   public extern static int IsWindowVisible(IntPtr hWnd);
  3.  
  4.   // And later in the code you would call it normally
  5.  
  6.   IsWindowVisible(hWnd);
  7.  

Thanks,
I thought it should be ok,but when I try to load the dll on another computer (not with VS2005) it fails to load (FileNotFoundException).
The dll is in the same dir with the exe. and the .net 2.0 framework is also installed.
Do you have any idea what could be the problem?

Thanks
Idit
Jan 26 '07 #3
Motoma
3,237 Expert 2GB
Thanks,
I thought it should be ok,but when I try to load the dll on another computer (not with VS2005) it fails to load (FileNotFoundException).
The dll is in the same dir with the exe. and the .net 2.0 framework is also installed.
Do you have any idea what could be the problem?

Thanks
Idit
I don't have any idea...perhaps you should us what compiler it is?
Jan 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to...
1
by: Geraldine Hobley | last post by:
Hello, I'm having a problem adding a manifest to a vb project in order to add visual styles to my vb.net application. I followed the steps outlined her...
7
by: Adam Maltby | last post by:
Hi, I am adding an new picbox and animated gif to it at runtime Dim img As Image = Image.FromFile(Application.StartupPath & "\animation.gif") With pic_Wait .Location = New Point(300, 250)...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
6
by: UJ | last post by:
I have a couple of files (type definitions, constants, ...) that I want to use in multiple projects. How do I make it so that I have only one copy of the file for multiple projects? If I do add...
4
by: Dinsdale | last post by:
I'm looking at adding scheduling features to an application and I wanted to ask the community about any experience with scheduling components, either open source like from code project or from a...
7
by: moondaddy | last post by:
I'm running a wpf windows app and want to add the appSettings element to the config file. when I do, the app wont start up and I get the following error: {"The type initializer for...
1
by: vinodkreddy1 | last post by:
hi good morning every body... i have a problem in adding Reference of any dll to asp.net 2005. i am trying to add dlls reference to asp.net application. but they r not adding to the reference...
4
by: ifitzgerald | last post by:
Hi, I am modifying a rather large and complex MFC application (written by someone else) written in Visual C++ 6.0 with service pack 6. I need to add serial communication functionality to the...
8
by: Jason | last post by:
Hello, I am trying to utilitze the AJAX Control toolkit in my asp.net project. I have added a reference to AjaxControlToolkit.dll, and in my page, added these lines of code: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.