none
fatal error C1083: Cannot open type library file RRS feed

  • Question

  • hi,all, I turn on CLR support and make my MFC project mixed-mode, and add a reference to a .net code library, but i got the following error: 
    1>c:\my documents\visual studio 2010\projects\xmldomfromvc\stdafx.h(50): fatal error C1083: Cannot open type library file: 'd:\htmlagilitypack.1.4.0\htmlagilitypack.dll': Error loading type library/DLL.
    This is my import statement:
    #import "D:\HtmlAgilityPack.1.4.0\HtmlAgilityPack.dll"
    so, what went wrong?
    cheers
    daiyue
    Monday, May 23, 2011 10:32 PM

All replies

  • Sanity question: does the file exist? Is the spelling correct? Can you open it manually using OLEVIEW?
    Tuesday, May 24, 2011 4:22 AM
  • You can also include the dependency DLL or lib files in the following Visual studio option

    Project -> Properties -> Configuration Properties -> Linker ->General -> Additional Library Directories
    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Tuesday, May 24, 2011 5:13 AM
  • Sanity question: does the file exist? Is the spelling correct? Can you open it manually using OLEVIEW?
    the dll file does exist
    • Proposed as answer by stereosphere Wednesday, September 3, 2014 11:47 PM
    Tuesday, May 24, 2011 10:56 AM
  • You can also include the dependency DLL or lib files in the following Visual studio option

    Project -> Properties -> Configuration Properties -> Linker ->General -> Additional Library Directories
    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    yea, i am able to add the library using this way, but still got the same error when i import it.
    Tuesday, May 24, 2011 10:57 AM
  • Hi,

     

    According to your description, it seems that you have an issue about loading DLL.

     

    There are several cause which can make Error C1083, such as spelling, file not exist or read-only file etc. Based on your description, I have notice that  you have a .Net library. So it should  use CLR. However the compiler option /clr is not specified. You can follow these steps to set the option:

    1.       In Solution Explorer, right-click the project name, and then click Properties to open the project Property Pages dialog box.

    2.       Select the Configuration Properties folder.

    3.       On the General property page, modify the Common Language Runtime support property.

     

    For more information about the optionhttp://msdn.microsoft.com/en-us/library/k8d11d4s.aspx.

     

    I hope my suggestion can help you to resolve your issue.

     

    Best Regards,

    Rob

     


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 25, 2011 6:41 AM
  • hi,thx for your reply, I did modify the Common Language Runtime support property to turn on /clr support, but it didnt work, i also check the file, it did exist and is not read-only, and the spelling is correct too.

    I am really confused here.

    cheers

    daiyue 

    Wednesday, May 25, 2011 1:18 PM
  • You don't have import this .NET reference DLL. If you want create sample program for htmlagilitypack, you can do the following steps.

     

    1) Create CLR project (CLR -> CLR Console Application for sample)

    2) Project->Properties->Common Properties-> framework and Reference

            Add New Reference ->browse-> Browse the DLL and add into the reference

    3) Run the sample application using HtmlAgilityPack namespace

     

    Note 1: IF you are looking for unmanaged(native) C++, you have to use pInvoke for access .NET assembly. You can check http://htmlagilitypack.codeplex.com/discussions/79822. But, you won't get any solution from there.

    Note 2: If you want learn more about #import, you can check http://msdn.microsoft.com/en-us/library/8etzzkb6%28v=vs.71%29.aspx

     


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Wednesday, May 25, 2011 4:38 PM
  • You don't have import this .NET reference DLL. If you want create sample program for htmlagilitypack, you can do the following steps.

     

    1) Create CLR project (CLR -> CLR Console Application for sample)

    2) Project->Properties->Common Properties-> framework and Reference

            Add New Reference ->browse-> Browse the DLL and add into the reference

    3) Run the sample application using HtmlAgilityPack namespace

     

    Note 1: IF you are looking for unmanaged(native) C++, you have to use pInvoke for access .NET assembly. You can check http://htmlagilitypack.codeplex.com/discussions/79822. But, you won't get any solution from there.

    Note 2: If you want learn more about #import, you can check http://msdn.microsoft.com/en-us/library/8etzzkb6%28v=vs.71%29.aspx

     


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    hi, I have a MFC dialog-based project, and i want to use htmlagilitypack to handle html source code.
    Wednesday, May 25, 2011 7:58 PM
  • Hi,

     

    There are generally two ways to add your .net dll.

    1.    Make your MFC application have common language support (/clr), add the .NET dll as a reference to your project, and then you can consume the types defined in the .Net dll directly.

     

    2.    Wrap the .Net dll as a COM component, register the COM component with tools such as Regasm, and then consume the COM component in your MFC application. To consume a COM component in MFC, there are three way:

     

    1). Use APIs such as CoCreateInstance.

    2). Use #import directive

    3). Select “MFC class from typelib” in the “Add Class” dialog, and then choose the typelib file generated by Regasm. The IDE will generate wrapper class for COM component.

     

    You can refer to article below, which includes detail steps for calling managed .NET COM object from unmanaged C++ code.

     http://www.codeproject.com/KB/cs/ManagedCOM.asp

     

    Besides, you can refer to following threads

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3076523&SiteID=1

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3046102&SiteID=1

     

     

    In additional, if you can post us some sample about your issue. we can resolve your issue more effective.

     

    I hope my suggestion can help you to resolve your issue. If anything is unclear, please feel free and let me know.

     

    Best Regards,

    Rob


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 26, 2011 7:38 AM
  • Hi,

     

    There are generally two ways to add your .net dll.

    1.    Make your MFC application have common language support (/clr), add the .NET dll as a reference to your project, and then you can consume the types defined in the .Net dll directly.

     

    2.    Wrap the .Net dll as a COM component, register the COM component with tools such as Regasm, and then consume the COM component in your MFC application. To consume a COM component in MFC, there are three way:

     

    1). Use APIs such as CoCreateInstance.

    2). Use #import directive

    3). Select “MFC class from typelib” in the “Add Class” dialog, and then choose the typelib file generated by Regasm. The IDE will generate wrapper class for COM component.

     

    You can refer to article below, which includes detail steps for calling managed .NET COM object from unmanaged C++ code.

     http://www.codeproject.com/KB/cs/ManagedCOM.asp

     

    Besides, you can refer to following threads

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3076523&SiteID=1

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3046102&SiteID=1

     

     

    In additional, if you can post us some sample about your issue. we can resolve your issue more effective.

     

    I hope my suggestion can help you to resolve your issue. If anything is unclear, please feel free and let me know.

     

    Best Regards,

    Rob


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    I tried the first method to add the .net dll, and tried something like:

    HtmlDocument doc = new HtmlDocument();

    but i got the following errors:

    error C2065: 'HtmlDocument' : undeclared identifier
    error C2146: syntax error : missing ';' before identifier 'doc'
    error C2065: 'doc' : undeclared identifier
    error C2061: syntax error : identifier 'HtmlDocument'

    I then tried the 2nd method, that I follows a article on:

    http://support.microsoft.com/kb/828736

    registered the htmlagilitypack.dll using RegAsm, and generate htmlagilitypack.tlb; then I imported the tlb file in my unmanaged project; since I couldnt find any interface name in htmlagilitypack, so i tried to call the managed dll, like this:

    HtmlDocument doc = new HtmlDocument();

    and i got the following errors:

    error C2079: 'doc' uses undefined struct 'HtmlAgilityPack::HtmlDocument'
    error C2512: 'HtmlAgilityPack::HtmlDocument' : no appropriate default constructor available
    ps. i also added "using namespace HtmlAgilityPack;" in stdafx.h. 

    I checked the source code of HtmlDocument in htmlagilitypack:

    public class HtmlDocument : IXPathNavigable
    {
    }
    so it implements IXPathNavigable interafce?

    cheers

    daiyue 



    Thursday, May 26, 2011 3:27 PM
  • Hi daiyueweng,

     

    According to your error message, You need to add namespace of your .Net DLL such as using namespace ClassLibrary1;

     

    In the second method, the error message show that you need to define an appropriate constructor.   For more detail please check http://msdn.microsoft.com/en-us/library/9zkz8dx6.aspx

     

    If you don’ mind, you can also send your sample code to help us to find your issue.

     

    If anything is unclear, please feel free and post to the MSDN forum.

     

    Best Regards,

    Rob

     


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 30, 2011 5:56 AM

  • HtmlDocument doc = new HtmlDocument();

    and i got the following errors:

    error C2079: 'doc' uses undefined struct 'HtmlAgilityPack::HtmlDocument'
    error C2512: 'HtmlAgilityPack::HtmlDocument' : no appropriate default constructor available
    ps. i also added "using namespace HtmlAgilityPack;" in stdafx.h. 

    I checked the source code of HtmlDocument in htmlagilitypack:

     

    public class HtmlDocument : IXPathNavigable
    {
    }
    
    so it implements IXPathNavigable interafce?

    cheers

    daiyue


    yes. HtmlDocument implements interface IXPathNavigable only. It look like, the HtmlDocument doesn't implement the default const. So,you have to check and pass appropriate input for HtmlDocument(It might be xml file name. Check the htmlagilitypack document)

    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Monday, May 30, 2011 6:05 AM
  • Hi daiyueweng,

     

    According to your error message, You need to add namespace of your .Net DLL such as using namespace ClassLibrary1;

     

    In the second method, the error message show that you need to define an appropriate constructor.   For more detail please check http://msdn.microsoft.com/en-us/library/9zkz8dx6.aspx

     

    If you don’ mind, you can also send your sample code to help us to find your issue.

     

    If anything is unclear, please feel free and post to the MSDN forum.

     

    Best Regards,

    Rob

     


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    hi, how to send you my project? it is like over 40mb for the original one, i will try to make a sample out of it.

    The sample project is called "usingHtmlAgilityPack" created in VC10, a MFC dialog-based one;

    Since the HtmlAgilityPack is a managed code library, it contains HtmlAgilityPack.snk, and i changed something in AssemblyInfo.cs

    [assembly: ComVisible(true)]

    keeps other settings intact.

    then I used RegAsm.exe to generate HtmlAgilityPack.tlb, and import it into to the unmanaged project (MFC dialog-based) in stdafx.h like this:

    #import "D:\htmlagilitypack-85383\Release\1_4_0\HtmlAgilityPack\bin\Debug\HtmlAgilityPack.tlb" raw_interfaces_only
    using namespace HtmlAgilityPack;

    you may need to change the path name to the tlb file, and I will include the HtmlAgilityPack source package.

    then I added the following lines of code in OnInitDialog():

    // TODO: Add extra initialization here
    	// Initialize COM
    	CoInitialize(NULL);
    	HtmlDocument doc = new HtmlDocument();

    and when i built the project, it generated the above errors.

    I have also checked the HtmlAgilityPack source, there is a default constructor in HtmlDocument class.

    #region Constructors
    
      /// <summary>
      /// Creates an instance of an HTML document.
      /// </summary>
      public HtmlDocument()
      {
       _documentnode = CreateNode(HtmlNodeType.Document, 0);
      }
    
      #endregion

    cheers

    daiyue



    Monday, May 30, 2011 12:30 PM
  • Hi daiyueweng,

     

    You can send your sample to skydrive and post me the link of you sample.

     

    In addition, here is my solution about invoke .net DLL from C++ .

    1. http://cid-ae2442667686801e.office.live.com/self.aspx/.Documents/ClassLibrary1.rar

    2. http://cid-ae2442667686801e.office.live.com/self.aspx/.Documents/InteropWithNativeCode.rar

     

    I hope my suggestion can help you to resolve your issue. If anything is unclear, please feel free and let me know.

     

    Best Regards,

    Rob


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 1, 2011 6:23 AM
  • Hi daiyueweng,

     

    You can send your sample to skydrive and post me the link of you sample.

     

    In addition, here is my solution about invoke .net DLL from C++ .

    1. http://cid-ae2442667686801e.office.live.com/self.aspx/.Documents/ClassLibrary1.rar

    2. http://cid-ae2442667686801e.office.live.com/self.aspx/.Documents/InteropWithNativeCode.rar

     

    I hope my suggestion can help you to resolve your issue. If anything is unclear, please feel free and let me know.

     

    Best Regards,

    Rob


    Rob Pan [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    I have uploaded my sample project and htmlagilitypack to skydrive:

    sample project:

    http://cid-daa7dd9334d69800.office.live.com/self.aspx/Public/usingHtmlAgilityPack.rar

    htmlagilitypack:

    http://cid-daa7dd9334d69800.office.live.com/self.aspx/Public/htmlagilitypack-85383.rar

    cheers

    daiyue

    Wednesday, June 1, 2011 3:39 PM