Could not load file or assembly 'Microsoft.SqlServer.Types

Posts   
 
    
llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 16-Aug-2018 16:37:13   

Microsoft SQL Server 2012 sp 1 LLBLGen Pro version: v3.5. Build: April 20th, 2012

Sorry for the newbie question here, but I'm a recent college grad that is still wet behind the ears. As part of the process where I work, whenever a change is made to the DB (table / stored procedure added, etc.), we open the project source folder (in this case a .net 4.0 solution) then drill down to the LLBL > AdapterV35 folder and then open up a "ConvertedProjectV35Format.llblgenproj" file. It opens with LLBLGen Pro v3.1. Up until now, I haven't had any problems, however, yesterday, when I tried opening it, I got the following message:

Exception information.

LLBLGen Pro version: v3.5. Build: April 20th, 2012

Exception details:

Message: Error occured when reading the following xml:''. Source: SD.LLBLGen.Pro.DBDriverCore Stack trace: at SD.LLBLGen.Pro.DBDriverCore.DBTable.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBSchema.DeserializeTables(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBSchema.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBCatalog.DeserializeSchemas(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBCatalog.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.ApplicationCore.MetaData.DatabaseMetaData.DeserializeCatalogs(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.ApplicationCore.MetaData.DatabaseMetaData.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.ApplicationCore.MetaData.MetaDataStore.DeserializeTargetDatabase(XmlReader reader) at SD.LLBLGen.Pro.ApplicationCore.MetaData.MetaDataStore.DeserializeFromReader(XmlReader reader) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.DeserializeFromReader(XmlReader reader, String additionalTypeConverterFolder) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.Load(String filename, String additionalTypeConverterFolder) at SD.LLBLGen.Pro.Gui.Classes.GuiController.PerformOpenProjectAction(String filenameToOpen)

Inner exception:-----------------------

Exception details:

Message: Could not load file or assembly 'Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. Source: mscorlib Stack trace: at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError) at SD.LLBLGen.Pro.DBDriverCore.DBTypeDefinition.DeserializeFromReader(XmlReader localReader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBField.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance, DBSchema containingSchema) at SD.LLBLGen.Pro.DBDriverCore.DBTable.DeserializeFields(XmlReader reader, DBDriverBase driverInstance) at SD.LLBLGen.Pro.DBDriverCore.DBTable.DeserializeFromReader(XmlReader reader, DBDriverBase driverInstance)

Inner exception: <null>

Googling around has not produced much, and the senior developer here is busy with another project so I thought I would see if anyone here could help.

Sorry if my query has been answered elsewhere. I have looked at http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=24705&HighLight=1 and a couple other posts from the llbl forum, but haven't been able to make much sense of what the problem could be. Please let me know if I need to provide additional information.

Thanks much for your help.

Best, Jon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 16-Aug-2018 16:51:34   

Please reference the MicrosoftSqlServer.Types dll from the sql server folder, e.g. c:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.Types.dll

or reference the package from Nuget. https://www.nuget.org/packages/Microsoft.SqlServer.Types/

The nuget package has a different version though, so you have to add an assembly redirect to your application's config file if it doesn't load.

The dll is referenced if you use spatial types in sql server, as that's the dll which implements geography etc. types inside sqlserver. As the types have to match on client and server side, you need to reference the dll on the client side to use the types (otherwise you can't create geography etc. type instances)

Frans Bouma | Lead developer LLBLGen Pro
llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 16-Aug-2018 18:43:45   

Otis, thank you for your quick response. I'm not sure how to reference the MicrosoftSqlserver.Types dll. I found the folder it is in (C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies), but I don't know how to reference it.

Otis wrote:

Please reference the MicrosoftSqlServer.Types dll from the sql server folder, e.g. c:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.Types.dll

or reference the package from Nuget. https://www.nuget.org/packages/Microsoft.SqlServer.Types/

The nuget package has a different version though, so you have to add an assembly redirect to your application's config file if it doesn't load.

The dll is referenced if you use spatial types in sql server, as that's the dll which implements geography etc. types inside sqlserver. As the types have to match on client and server side, you need to reference the dll on the client side to use the types (otherwise you can't create geography etc. type instances)

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-Aug-2018 20:29:39   
llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 16-Aug-2018 20:31:26   

Thank you Walaa! I'll check it out! simple_smile

Walaa wrote:

Here you are: Errors due to missing types dll and how to solve them

llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 17-Aug-2018 18:05:09   

So I read the article you shared a link to, as well as other articles. From the article you shared, it appears there could be one of 2 problems. 1: I don't have SQL Server client tools installed locally (I believe do... at least I have Sql server management studio installed) or 2: I'm missing the the Microsoft.SqlServer.Types.dll file. I'm guessing I'm missing the .dll. So I figured I would try to learn about the GAC. One of the articles I looked at was https://docs.microsoft.com/en-us/dotnet/framework/app-domains/gac and it seems that there are two possible locations for the GAC (C:\Windows\assembly\GAC [I'm able to view the folder structure of the GAC here because I followed the instructions here: http://geekswithblogs.net/khanna/archive/2004/11/01/14150.aspx] and another location C:\Windows\Microsoft.NET\assembly which contains GAC_32, GAC_64, and GAC_MSIL). How do I know which location llblgen is referencing? Also after searching for the Microsoft.SqlServer.Types.dll in the GAC folder, I don't see it. One of my co-workers has just found a copy of the dll and put it in there (a long time ago when he had the problem), but he said doing that caused other problems. Any further suggestions would be much appreciated. llblboy wrote:

llblboy wrote:

Thank you Walaa! I'll check it out! simple_smile

Walaa wrote:

Here you are: Errors due to missing types dll and how to solve them

llblboy
User
Posts: 15
Joined: 18-Apr-2018
# Posted on: 17-Aug-2018 21:24:01   

This was resolved by installing SQLSysClrTypes (x64) v11.msi. It added the missing dll to the GAC.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Aug-2018 09:21:25   

using gacutil -i <assembly> also works in most cases. Sorry for this inconvenience, it's the only way to get the types working, sadly... disappointed

Frans Bouma | Lead developer LLBLGen Pro