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"...
March 3rd, 2004, 05:22 PM
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.
March 4th, 2004, 06:23 PM
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,
March 4th, 2004, 07:21 PM
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.)
March 4th, 2004, 09:28 PM
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....
March 4th, 2004, 09:33 PM
I just looked around on your website. You have some Automation Control examples that I'll study a bit closer...maybe they will help.
March 4th, 2004, 09:59 PM
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.
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.
March 5th, 2004, 07:08 PM
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:
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.
March 5th, 2004, 09:18 PM
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"...
March 5th, 2004, 11:05 PM
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:
// 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.
March 5th, 2004, 11:31 PM
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).
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 :)
March 6th, 2004, 04:21 AM
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.
March 6th, 2004, 11:25 AM
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.
March 6th, 2004, 01:14 PM
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?
March 6th, 2004, 01:32 PM
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.