Tony Sullivan
Tony Sullivan

Reputation: 45

Unable to load a .Net assembly

I am attempting to access a .Net assembly in a VB program running on a server. I am receiving the often mentioned Could not load file or assembly error. I have been through about 60 different web pages and nothing I have done has fixed it.

I have the dll in the same directory as the executable I am launching. In the Appbase it is showing file://?/c: and in the other examples that I have seen researching this, they all had file:///. I don't know if that could be the issue or not. If it is, can anyone tell me how to fix it? I have tried searching for file://?/ but that ignores all of the special characters even when enclosed in question marks in Google and Bing, as best I can tell.

Error Message:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'cgiTest.modCurrentBalance' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.
File name: 'Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'
   at cgiTest.modCurrentBalance..cctor()

=== Pre-bind state information ===
LOG: User = WEBSERVER1\Administrator
LOG: DisplayName = Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
 (Fully-specified)
LOG: Appbase = file://?/c:/inetpub/intranet/
LOG: Initial PrivatePath = NULL
Calling assembly : cgiTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abaf442583423e6f.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells.DLL.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells/Aspose.Cells.DLL.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells.EXE.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells/Aspose.Cells.EXE.

   --- End of inner exception stack trace ---
   at cgiTest.modCurrentBalance.GenerateReport()
   at cgiTest.Module1.ProcessFunction() in q:\visual studio 2010\Projects\cgiTest\cgiTest\Module1.vb:line 65
   at cgiTest.Module1.Main() in q:\visual studio 2010\Projects\cgiTest\cgiTest\Module1.vb:line 41

Upvotes: 1

Views: 2132

Answers (3)

Tony Sullivan
Tony Sullivan

Reputation: 45

I was finally able to get this to load by using the event handler described at http://support.microsoft.com/kb/837908.

At this point I am not certain why I had to go this route, but it is working by me specifying the path where both the binary and dll are located, which should be the default behavior.

The only thing I can figure is that it has something to do with the question mark in the file path "file://?/" where it is looking for the dll, but I have no idea why the question mark is there.

Upvotes: 1

David Young
David Young

Reputation: 1

Shouldn't the DLL be inside the BIN folder of your application? When your app compiles it will look there for the assemblies.

Upvotes: 0

Avner Shahar-Kashtan
Avner Shahar-Kashtan

Reputation: 14700

Does the user under which the program is executing have permissions to access the file and the folder? It may be that the file was moved, rather than copied, from a folder with different ACLs, and the code can't access it.

Best way to check is to get Process Monitor, configure its filter to only show access to Paths containing "Aspose.Cells", and see what processes try to access the file, if they fail, and if so - why.

Upvotes: 1

Related Questions