Friday, February 24, 2012

Error: Unable to load one or more of the requested types.

When I'm trying to deploy a SQLCLR assembly , I get the following error:

Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

This is an error you get were you cannot get the assembly types during reflection.

I was able to deploy it previously, and I'm not aware of any change I made that could make it refer to a different external type.

It has a reference to another SQLCLR assembly that was successfully deployed. If I remove all the references in in the code to classes in that assembly, it works OK, so it looks that it cannot load this other assembly when trying to deploy the first one.

Is there any way to troubleshoot this? Getting that 'LoaderExceptions property' could be useful..

Any other hint?

Thanks

Are you using reflection against types that are in assemblies that are also registered in the database? or these are assemblies that are were not registered using CREATE ASSEMBLY? if it's the later, that's by design, you cannot load assemblies that were not registered with SQL Server.

Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

|||Thanks Pablo.

I run into this issue again today, and it looks like a VS.NET thing.

I create two projects, one with an enumeration:

public enum MyEnum
{
MyValue,
MyValue2
}

and another project with a reference to the first one, that declares a variable of that enumeration type

MyEnum myEnum;

Then when I try to deploy the second project, I get

Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

But, I execute the CREATE ASSEMBLY commands, then it works OK. The weird thing is that in my real world case, I could deploy the assemblies without any problem and now I cannot.

So, it looks like a VS.NET issue. I'm not sure which is the right forum to post it ;)

|||Please make sure that the top level assembly was compiled against the version of the referenced assembly that is in the assembly.

- Balaji Rathakrishnan|||It looks that it was caused by a versioning issue. Even if I tried that before, it looks that setting a '1.0.0.0' version fixed the problem.

Thanks a lot.

Andres|||

Sir,

i am also facing the same problem.

first i refered the assembly from local. at that time it is working properly.

but now i moved assemblies to GAC ,now it shows the above mentioned error.

i seen the abve answers.

can u tell me how to run the CREATE ASSEMBLY commend.

thanks

No comments:

Post a Comment