fail to load DLL on non dev machine

0

C# DLL Loading Issue

I am developing an program that takes an XML config and progresses through a series of tasks, as an addition to our Automation at work.

We've created wrappers from common utilities / procedures, which compile into .dlls to be loaded at run time which inherit from an Interface. The program reads the XML config, loads the correct dll, casts it as a type of the interface, calls it's init() method passing it arguments from the XML file and if it receives the correct return code, calls it's start() method.

These dlls can be doing anything from in-house/3rd party application automation to environment operations.

This works perfectly on the Dev machine, I have 4 different tasks laid out in the XML file, when run the program calls the right dlls, cast, and run through their automation tasks. However, when I move to any other machine apart from the Dev machine, I get a COM error when trying to cast the DLL.

Exception has been thrown by the target of an invocation.
System.Runtime.InteropServices.COMException(0x80040154):Retrieving the COM class factory component with CLSID
{1A671297-FA74-4422-80FA-6C5D8CE4DE04} failed due to the following error: 80040154 Class not registered (Exception HRESULT: 0x80040153 (REGDB_E_CLASSNOTREG))

Each module is made in it's own solution in VS2010 and references the same moduleInterface.dll as the main project. I've seen the COM error before when a module wasn't implementing the interface and was missing a method, it threw this exception because it didn't implement the correct set of methods to be cast as a type of this interface. However, these modules are definitely working.

This is how I'm loading and casting the modules

Assembly test = Assembly.LoadFile(Path.Combine(Prefs.ModulePath, tmodule));
Console.Write("Getting type..\r\n");              
Type type = test.GetTypes().FirstOrDefault();               

Console.Write("Casting module\r\n");
currentModule = (Imodule.Imodule)Activator.CreateInstance(type);   

It also runs properly on a second Dev machine which has vs2010 installed, which makes me think I'm missing some runtime distributable? I've tested this on Win7x64, Win8.1x64, Win8x86, Server 2008 R2 and all fail to cast the module properly.

Kinda running out of ideas now, and I'm fairly new to C# and don't really know what to try next.

c#
.net
dll
asked on Stack Overflow Feb 19, 2014 by turtle342 • edited Feb 19, 2014 by John Saunders

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0