1

I'm getting an error that is baffling me complete. I have a .NET Application that pulls in a reference to an OCX file used to automate a 3rd party program. This applications works perfectly when I run it from within Visual Studio, but when I package it in an MSI file and install it on a test machine, it fails saying "Could not load file or assembly "Interop.OISSERVERLib, ...".

Does anyone have any suggestions on how I can deal with this?

System.InvalidOperationException was unhandled
Message=An error occurred creating the form. See Exception.InnerException for details.  The error is: Could not load file or assembly 'Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source=SLSClaimantWorkbook
StackTrace:
   at SLSClaimantWorkbook.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
   at SLSClaimantWorkbook.My.MyProject.MyForms.get_SLSClaimantWorkbook()
   at SLSClaimantWorkbook.My.MyApplication.OnCreateMainForm() in C:\Documents and Settings\C15919\My Documents\Visual Studio 2005\Claimant Workbook\Claimant Workbook\My Project\Application.Designer.vb:line 35
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at SLSClaimantWorkbook.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
InnerException: System.IO.FileNotFoundException
   Message=Could not load file or assembly 'Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   Source=SLSClaimantWorkbook
   FileName=Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   FusionLog=WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   StackTrace:
        at SLSClaimantWorkbook.SLSClaimantWorkbook..ctor()
   InnerException: 

EDIT: Assembly binding info:

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  c:\WINNT\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files\SLS\Claimant Workbook\SLSClaimantWorkbook.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = INTERNAL\C15919
LOG: DisplayName = Interop.OISSERVERLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/SLS/Claimant Workbook/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = SLSClaimantWorkbook.exe
Calling assembly : SLSClaimantWorkbook, Version=0.9.31.11788, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\SLS\Claimant Workbook\SLSClaimantWorkbook.exe.config
LOG: Using machine configuration file from c:\WINNT\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib/Interop.OISSERVERLib.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/SLS/Claimant Workbook/Interop.OISSERVERLib/Interop.OISSERVERLib.EXE.
LOG: All probing URLs attempted and failed.
Dan Champagne
  • 890
  • 2
  • 17
  • 37
  • Could you post the full error message? – Yam Marcovic Oct 11 '11 at 00:12
  • 2
    You forgot to deploy the interop library, required. Next possible failure mode is forgetting to deploy and register the OCX file on the target machine. – Hans Passant Oct 11 '11 at 00:36
  • Yam, I've added the full error text. – Dan Champagne Oct 11 '11 at 11:49
  • The interop library is being deployed with the package. I'm not sure why it can't find it. Is there a way I can change where the application looks for the file on startup? – Dan Champagne Oct 11 '11 at 11:53
  • 2
    Have you tried turning assembly binding logging on? http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net – Matt Evans Oct 11 '11 at 12:02
  • I've added the assembly binding info from the log. I'm unfamiliar with this, but it looks like it's trying to find a file named "Interop.OISSERVERLib.DLL", but the actual reference file added to Visual Studio is "OisServer.OCX". Is there a way to change the file the application is looking for? – Dan Champagne Oct 11 '11 at 12:45

1 Answers1

0

This error is because of my limited understand of how Visual Studio processes OCX files. When I added the file as a reference in the program, the program created "Interop.OISSERVERLIB.dll" and the program was using that file, not the original OCX. By browsing to the "bin\Debug" folder, I was able to add the DLL to the install file, and it is now working correctly!

Thank you all for pointing me in the right direction!

Dan Champagne
  • 890
  • 2
  • 17
  • 37
  • 3
    Just for those finding this in future, there should also be a reference to the Interop dll in the project references. Make sure that `Copy Local` is set to true to output it when you build/publish/deploy – Basic Feb 18 '13 at 11:41