Sql Server 2005 User Defined Types and the “File or assembly name not found” exception.


"File or assembly name ‘<udtname>’, Version=1.2.0.0, Culture=neutral, PublicKeyToken=389619d4c1235f8a', or one of its dependencies, was not found."

If you have started using Sql Server 2005 User Defined Types it is likely that you have run into the exception above. Why is this happening? The short answer is that Fusion has not been able to find your UDT on the client.

 

Introducing fuslogvw.exe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptutorials/html/assembly_binding_log_viewer_resources.asp

The link above is the best I have been able to find, but it is out of date for the 2.0 framework. Fuslogvw.exe is a tool included in the SDK that allows you to look at fusion related logs.

To start using v2.0 of fuslogvw.exe click on “Settings” and choose “log bind failures to disk”, then Enable custom log path and enter a valid directory name.

Re-run your app and click “Refresh” to see the fusion related log entries. You need to double click on the Application column to see the actual log.

 

Example log file:

I registered a UDT called Udt_NewHugeInteger on the server and attempted to retrieve it from the client without having the udt dll locally or in the gac, here is the fuslogvw log.

*** Assembly Binder Log Entry  (9/9/2004 @ 7:56:18 PM) ***
 
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
 
Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.<version>\mscorwks.dll
Running under executable  
--- A detailed error log follows.

=== Pre-bind state information ===

LOG: User = REDMOND\<somebody>

LOG: DisplayName = Udt_NewHugeInteger, Version=1.2.0.0, Culture=neutral, PublicKeyToken=<sometoken>

 (Fully-specified)

LOG: Appbase = file:///C:/scratchpad/DataViewer/Whidbey/

LOG: Initial PrivatePath = NULL

LOG: Dynamic Base = NULL

LOG: Cache Base = NULL

LOG: AppName = DataViewer.exe

Calling assembly : System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=<sometoken>

===

LOG: This bind is in default load context.

LOG: No application configuration file found.

LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.<something>\config\machine.config.

LOG: Post-policy reference: Udt_NewHugeInteger, Version=1.2.0.0, Culture=neutral, PublicKeyToken=<sometoken>

LOG: GAC Lookup was unsuccessful.

LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger.dll.

LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger/Udt_NewHugeInteger.dll.

LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger.exe.

LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger/Udt_NewHugeInteger.exe.

LOG: All probing URLs attempted and failed.

 

 

As you can see first we searched in the GAC

       LOG: GAC Lookup was unsuccessful.

Then we attempted to load from the local directory:

       LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger.dll.

       LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger/Udt_NewHugeInteger.dll.

       LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger.exe.

       LOG: Attempting download of new URL file:///C:/scratchpad/DataViewer/Whidbey/Udt_NewHugeInteger/Udt_NewHugeInteger.exe.

 

When we fail to find Udt_NewHugeInteger, Version=1.2.0.0 in any of these locations we get the file not found exception.

Ok, so how do you fix it? Drop your dll into one of the directories shown above and re-start your application (it may not work without re-starting). You should be good to go.

 

Is this really all there is to fusion and User Defined Types? No of course not, more to blog at another time.

 

Rambling out: Standard disclaimer: This post is provided AS IS and confers no rights.

Comments (0)

Skip to main content