none
WIndows Form Application- How to add reference?

    General discussion

  • Hi! I have created a Win32 Console application(c++). Built it and got the required Dll and now i wish to call the same in a Windows Form Application. When i try to ADD the DLL in reference options i Get an error stating:

    " Could not add a reference to file 'C:\users\..........\pingu.dll' because it is neither a .Net Assembly nor a registered ActiveX Control'

    I am currently using VS 2010. I am trying to access a certain function which i have already created in the console project. I have linked and included the lib files and directories(respectively) in the form application properties. But can't add reference to it.

    How do i reference the DLL?

    please let me know if you require any more info!!


    Thursday, March 08, 2012 3:27 PM

All replies

  • Hi sheetansh,
    Is it a native C++ assembly? Are you trying to reference a native C++ assembly from VC++?
    If so, see http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/8797b191-4f74-427b-bbf6-2bcbb2bdbdb0
    If you are tring to reference a native C++ assembly from other .Net language, such as c# or VB, see http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/5df04db1-bbc8-4389-b752-802bc84148fe
    If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 09, 2012 7:23 AM
    Moderator
  • Thanks will try the suggestions and get back if i get stuck again!!

    Friday, March 09, 2012 4:03 PM
  • Hi sheetansh,
    I am writing to check the status of the issue on your side. 
    Is the issue solved?
    Would you mind letting us know the result of the suggestions?
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, March 13, 2012 6:33 AM
    Moderator
  • Hi! I truly appreciate your concern. I was able to understand my mistake but couldnt solve because i was stupid. looking at the errors i had immediately concluded it as a referencing error but after a recheck i relaised i had mistaken compile time error C2065. I had created a pointer in the header file of the DLL console application, which i inteded to use in the form applcation. currently i am confused if my C++ skills are sad or i am just not looking at the problem the right way.

    Following are the codes i made.

    //pingu.h - this is the header file i used for the console applcaiton.
    
    #pragma once
    
    #ifdef PINGU_EXPORTS
    #define PINGU_API __declspec(dllexport)
    #else 
    #define PINGU_API __declspec(dllimport)
    #endif
    
    class  PINGU_API  Initialize
    {
    public:  void Scan();
    public:  Initialize(void);
    public: ~Initialize(void);
    public: Initialize * ptr;
    
    
    
    
    };
    //pingu.cpp- in this cpp file i have tried to access a 
    //FTDI chip connected via USB. Scan() is the funciton 
    //i wish to access using a button in windows form.
    
    // pingu.cpp : Defines the exported functions for the DLL application.
    //
    
    #include "stdafx.h"
    #include "pingu.h"
    #include "ftd2xx.h"
    
    
    void Initialize :: Scan()
    {
    DWORD dwNumDevs;
    FT_STATUS FT_OpenEx;
    int iCount=0;
    FT_HANDLE m_ftHandle;
    int m_i64ComboBoxDeviceIDs[]={iCount};
    FT_STATUS ftStatus;
    FT_DEVICE_LIST_INFO_NODE *devInfo ;
    //
    // create the device information list
    ftStatus = FT_CreateDeviceInfoList(&dwNumDevs);
    if (ftStatus == FT_OK)
    {
    if(dwNumDevs > 0)
    {
    devInfo = new FT_DEVICE_LIST_INFO_NODE[dwNumDevs];
    if(devInfo)
    {
    ftStatus = FT_GetDeviceInfoList(devInfo,&dwNumDevs);
    if (ftStatus == FT_OK)
    {
    for(iCount = 0; iCount < (int) dwNumDevs; iCount++)
    {
    m_i64ComboBoxDeviceIDs[iCount] =(__int64) devInfo[iCount].SerialNumber;
    }}}}}};
    
    int main()
    {
     	return 0;
    }
    
    

    Now i know i can do the same using a constructor also. But that too doesnt work. it just keeps giving me C2065 and C2228. As far as the linking is considered i have done all that is required.  The "pingu.dll" , "pingu.lib" and pingu.h is linked using properties-> C/C++ ->general; properties->linker->general and Input. So i still need your help.

    Tuesday, March 13, 2012 4:55 PM
  • Hi sheetansh,
    I’m not able to help you on the compile issue as I’m not quite familiar with C++. I suggest you create a new thread in the Visual C++ General Forum.
    In addition, as the issue is not related to WinForm, would you mind change it to general discussion?
    Sorry for any inconvenience this may cause.
    Best regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 14, 2012 8:55 AM
    Moderator