CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: DLL Problem

  1. #1
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    DLL Problem

    Hi,
    I have a problem with my automation program.

    I created a new MFC dll using the VS6 MFC AppWizard (dll) and started building my automation control. I tested my program by loading my automation and everything was working fine. Then I added a resource to my project and my automation control have not been working since.

    I did some research and found that the link file myprogram.res had changed size to less than before. I opened the old one and compared it with the new file that was created when I compiled and found that a type "TYPELIB" was missing.

    Can anyone tell me what that "TYPELIB" type is and why my automation control does not work anymore?

    Btw. the dll gets registered fine, it's just when I try to use it it will error with "Could not load the selected Type Library"...

    John

  2. #2
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I really have no idea what the problem is. However since you are a Simi Valley resident, I will try to help.

    The res file is a temporary file, so I don't know how helpful it is.

    A Type Library is something that every Automation control must have. It is what clients use to interface with the server. So can you be more specific about what Type Library is missing? I think it is important to know if it is your server's type library or a type library of another server.

    What did you add to your resources that caused a problem? My guess is that whatever the problem is, the resource is just coincidental. However if you added something such as a Rich Edit control, then the problem might not related to your Automation control at all.

    So you need to tell us more.
    Last edited by Sam Hobbs; March 4th, 2004 at 08:21 PM.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  3. #3
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    Hi Sam,
    here is what happened:
    I want to create an Automation Control in Visual C++ 6.0.

    1. I use the AppWizard to create a MFC DLL with Automation enabled.
    2. I create a New Class for my Automation Interface.
    3. I use the Class Wizard to create Methods and Properties.
    4. I load my Automation Control in another development tool (Navision).

    Everything works great until now!

    5. Now I add a resource to my project, nothing more, I don't even reference it!

    Now my Automation control fails with the error "Could not load the selected Type Library"

    I know that the res file is temporary, but I referenced the res file because I noticed that my dll file got smaller after I added the resource, and the res file was the only file that had changed size.

    I compare the two files before and after I added my resource and found that the first had a reference to "TYPELIB", but the second didn't...

    Hope that explains some more...

    (The Knolls, is that at the end of Av. de Los Arboles?)

    Thanks for helping me out,
    John

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I have heard of Navision. I think it is something for accounting. Since you say it is a development tool (which is consistent with what I remember) I assume it is the programming environment that works with one of the accounting packages Microsoft purchased recently.

    I am sorry; either I don't know enough to help or there is something strange happening. I am not familiar with Navision enough to know what affect it can have.

    I still don't know what kind of resource was added; there is a good chance we are more likely to help if we knew what kind of resource was added. If it is a Navision thing, then probably there is something you are not doing that we would not know about; such as, perhaps you need to register it or initialize it.

    (The Knolls are at the southeast of the valley.)
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    I will try to be more specific.

    Navision is an accounting package that Microsoft bought last year.
    It has it's own development environment, very Delphi, Pascal and VB like.

    To be able to comunicate to external programs like Word, Excel or Outlook you can create a variable of ocx or Automation. I'm not doing anything in Navision with the automation control yet, Navision will not even let me create the variable if something is wrong with the dll. Before I added an Icon to my dll, I was able to create a very simple automation and use it in Navision, but when I created my dll with an Icon resource I could not make my variable in Navision.

    I'm trying to learn how to create these automation controls so I can add some nice features to Navision for our customers.

    I know most people create Automation Controls in VB, I could probably do that to but I have never used VB, so I want to use VC++ and MFC since I know these tools better.

    I tried to create an Icon resource and it failed, then I tried to create a Toolbar resource and that failed.

    I'm just wondering if I'm doing something wrong, is there a reference somewhere that I can look at, like a template to build an automation.
    I just ordered the book "Automation Programmer's Reference: Using Activex Technology to Create" I thought that could help me.

    Anyway I appreciate your time Sam, thanks alot!
    I like your website btw....

    John

  6. #6
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    I just looked around on your website. You have some Automation Control examples that I'll study a bit closer...maybe they will help.

    John

  7. #7
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    Ok,

    try this...entirely Visual C++ question.

    1. Create a new project using the wizard and MFC AppWizard(dll) with Automation turned on.

    2. Then compile this project in Release Configuration.
    3. Open the myproject.res file in release/ folder.
    Here you see a Type "TYPELIB" with some binary data in it.

    Now...
    4. Add a resource Menu to your project and Rebuild all.

    Now open the myproject.res file again and you'll notice that there is no longer a "TYPELIB" in the file anymore.

    I do not know if this is my problem, I just thought it was kinda odd.

    John

  8. #8
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Yes, I got the same results.

    The res files are compiled versions of the rc files. I saved a copy of the rc file before I added a dialog resource. In that version is the following:
    Code:
    1 TYPELIB "Problem.tlb"
    After adding a dialog resource, I looked at the rc file and that line is missing. So I am not sure, but I assume there is not a type library for the project. Probably the rc file was generated with a type library in the resources because it is normal for an automation project to have one. But then since we don't put anything into the type "library" the resource editor removes the one line for a type library the first time the resources are edited.

    I think that explains the behavior you are seeing and it makes sense. However I am making a few assumptions.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  9. #9
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    I there anyway to add code or run something that would add the "TYPELIB" back. There must be a process that I can go thru that would recreate that "TYPELIB"...

    John

  10. #10
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    There never was anything in the type library. It's like picking up the phone but never dialing anything.

    Look at your odl file. In it is a comment such as:
    Code:
    // This file will be processed by the MIDL compiler to produce the
    // type library (Problem.tlb).
    Have you put anything in there? That is the input for the type library.

    I do not remember writing a server using MFC so I am sorry that I am not likely to be able help much with what to do next, but probably you would not normally modify the odl file directly. Probably the ClassWizard will modify it and probably most of the modificatinos to the odl file will be done using the ClassWizard, but I am not sure. The important thing is that until you have added a property and/or method, there is nothing for a type library.

    I think you need to add a class. I don't know what you need to do to make the class support Automation, but you need to do that somehow. However you do it, you should use ClassWizard to create the class. Then use the Automation tab of the ClassWizard to add properties and/or methods. I am nearly certain that the type library will be created automatically when you do that.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  11. #11
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    Even though I did use the ClassWizard and added Methods and Properties it still didn't create my Typelib.

    Here is my odl file:
    // NaviCenter.odl : type library source for NaviCenter.dll

    // This file will be processed by the MIDL compiler to produce the
    // type library (NaviCenter.tlb).

    [ uuid(91C03765-C164-4F42-A08A-1CD5D64D5788), version(1.0) ]
    library NaviCenter
    {
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");




    // Primary dispatch interface for CMessageCenter

    [ uuid(337D1BD5-097F-4678-ADB0-7756798C7DFB) ]
    dispinterface IMessageCenter
    {
    properties:
    // NOTE - ClassWizard will maintain property information here.
    // Use extreme caution when editing this section.
    //{{AFX_ODL_PROP(CMessageCenter)
    //}}AFX_ODL_PROP

    methods:
    // NOTE - ClassWizard will maintain method information here.
    // Use extreme caution when editing this section.
    //{{AFX_ODL_METHOD(CMessageCenter)
    [id(1)] boolean Create();
    //}}AFX_ODL_METHOD

    };

    // Class information for CMessageCenter

    [ uuid(EA8DF5BA-E7B1-4DF6-B470-2284B5803A23) ]
    coclass MessageCenter
    {
    [default] dispinterface IMessageCenter;
    };

    //{{AFX_APPEND_ODL}}
    //}}AFX_APPEND_ODL}}
    };

    As you can see the ClassWizard added the method, but still didn't add the typelib.

    Thanks for your input Sam, it's been very helpful!

    I hope there is somebody out there that can help me out, maybe it's just a bug, and nobody knows about it because they make their automations without the Wizard, I just have to learn more about odl files so I can skip the wizard part

    John

  12. #12
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Did you build the project after creating the method? The type library would not be created by the ClassWizard; it would just update the odl file. You must compile the odl to create the type library.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  13. #13
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    Yes I did, and it does compile the library, but it doesn't insert the "TYPELIB".

    Maybe I can just open the .res file and import the .tlb file into it and build again so it will re-link.

    John

  14. #14
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Ignore the res file. The only thing you are likely to accomplish by looking at the res file is confusion.

    What do you mean when you say it doesn't insert the "TYPELIB". Insert where?
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  15. #15
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24
    Forget what I said, I'll try and insert the line: 1 TYPELIB "myprogram.tlb" in my .rc file, that should work.

    Apparently when I add the first resource to my project it overides the resource file that was created by the AppWizard with a new resource file.

    John

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured