I found the issue with this. I was debugging another issue with a library that had a similar name to one of my dependencies. It is trying to load this assembly and it cannot find it because I removed the file. I found this by enabling fusion logs. So, I had to search my machine for any references to it, which I found in my registry.
System.IO.FileNoteFoundException: Retrieving the COM class factory for the component
I am trying to load an assembly (lets call it MyAssembly.dll) on a remote 32 bit machine. The assembly itself is a code wrapper that handles interop assemblies related to the local hardware on the machine, and the reason I want to do this is so that when this is deployed I can make direct calls to the assembly.
Here is a snippet, and source of the problem:
private static object LoadInstance(string path, string type)
{
Assembly assembly = Assembly.LoadFrom(path);
return assembly.CreateInstance(typeName);
}
While it loads from the remote path, it will crash on the CreateInstance call. My thought is that the assembly I am loading cannot find the two dependancies. By the way - I did run an application directly on the remote computer and I was able to use the library.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'xxx.IO.xxxxx' threw an exception. ---> System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {8C6A0427-E3F2-11CF-B34A-00AA003C435E} failed due to the following error: 80070002 The system cannot find the file specified. (Exception from HRESULT: 0x80070002).
at xxx.IO.xxxxx..cctor()
--- End of inner exception stack trace ---
at xxx.IO.xxxxx..cctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName)
at someApp.Program.LoadInstance(String path, String typeName) in C:.....\Program.cs:line 58
at someApp.Program.Main(String[] args) in C:.....\Program.cs:line 41