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"...
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 07:21 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?)
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.
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....
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.
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.
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