Hi All,
Our application has a number of COM Interop assemblies which we initialise through reflection. Unfortunately since I moved to a new Development Environment I have been getting MissingMethodException's when calling these.
The error I am getting is:
System.MissingMethodException: Method 'System.__ComObject.method name' not found.
at ??.UseComObject(String ClassName, String MethodName, Object[] ParameterArray)
at ??.UseComObject(String ClassName, String MethodName, Object[] ParameterArray)
The method throwing the error has the following code:
Type myType = null;
object objClass = null;
myType = Type.GetTypeFromProgID(ClassName); // get the type of object based on its ProgId from the Registry.
objClass = Activator.CreateInstance(myType); // create an instance of the object.
// invoke the member, passing it the parameters
return myType.InvokeMember(MethodName, BindingFlags.InvokeMethod, null, objClass, ParameterArray);
If I change it to the following it works:
myType = Type.GetType(ClassName, true, true);
objClass = Activator.CreateInstance(myType); // create an instance of the object.
return myType.InvokeMember(MethodName, BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.OptionalParamBinding | BindingFlags.Static,
null, objClass, ParameterArray);
I do not get the issue with VB6 COM Components registered in COM+. It is only .NET Interop Components.
They are registered thorugh a batch file as follows:
%windir%\Microsoft.NET\Framework\v4.0.30319\RegSvcs.exe component name
I do not wish to change this code until I find the cause of the issue as it is only a problem on my environment. If the assemblies are compiled on a seperate environment they work as expected.
Thus far some of the things I have tried include:
- Check the interops are visble in COM+
- Removing any old assemblies from machine
- Restarting machine
- Doing several clean builds and registrations in COM+ and removals from COM+
- Got latest on project
- Changed GUID on Class
- Set version number of assembly
- Reinstall Visual Studio 2012
- Reinstall .Net Framework 4.5
- Checked the COM+ settings against other environments to ensure they are consistent.
Any help on this would be great before I give up and look to reinstall my environment from scratch.
Barry