Thursday, November 1, 2007

Automation Error System cannot find the file specified

You might run it to this problem when you are trying to load a COM exposed .net component from a COM application such as VB. The problem is that the COM is not able to find your component in the registry. Here are some of the resolutions you can try

- Enable Register for COM interop in the project properties window

This use to be enough in .Net 1.1 /VS 2003 to get the component registered. But in .Net 2.0/VS 2005, Microsoft introduced another way to specify the COM visibility. That is by introducing a new attribute [assembly: ComVisible(true)]. Add this attribute to your AssemblyInfo.cs file and recompile the project.

If you are still having the problem, try registering the component explicitly using

regasm c:\abc\abc.dll /tlb

sometimes the /tlb option does the trick.

If this doesn't fix the problem check the version number of the component on which your component depends on. If the components, on which your component depends, are singed with specific key and are of specific version, then your component also need to be signed with the same key and versioned the same. Otherwise you will get the same automation error when loading from the component from a COM client. In .Net2.0 you update the AssemblyInfo.cs to update the version number and sign the component

e.g.

[assembly: AssemblyVersion("x.x.x.x")]
[assembly: AssemblyFileVersion("x.x.x.x")]

[assembly: AssemblyKeyFile(@"your_key.snk")]

Hope this helps.