Giter Site home page Giter Site logo

Comments (10)

dotMorten avatar dotMorten commented on May 26, 2024

I believe this is just a known limitation of using custom CLR types that are essentially different from the ones SqlServer uses (while they are the same in functionality and namespace, they are different because the assemblies each of them are defined in aren't signed with the same key, and there's not really any way I can "fake" that).

from microsoft.sqlserver.types.

dotMorten avatar dotMorten commented on May 26, 2024

Actually try adding this to your application startup:

private static void Init()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
private static System.Reflection.Assembly? CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name == "Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" ||
args.Name == "Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" ||
args.Name == "Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")
return typeof(SqlGeography).Assembly;
return null;
}

from microsoft.sqlserver.types.

vishnu4 avatar vishnu4 commented on May 26, 2024

Unfortunately that didn't work for me, i even tried SqlGeometry (since that is what i'm generally using) and still no good.

Does it matter where in startup.cs it's run? I had it running in Configure near the beginning, but not sure if other options were better.

Thanks!

from microsoft.sqlserver.types.

dotMorten avatar dotMorten commented on May 26, 2024

I’ve actually been unable to reproduce this. Even the unit tests “just works” with that API call.
Any chance you could share a self-contained application that reproduces this?

from microsoft.sqlserver.types.

dotMorten avatar dotMorten commented on May 26, 2024

Another thing you could try that might just do the trick is to explicitly load the assembly up-front before querying anything.

from microsoft.sqlserver.types.

dejanberic avatar dejanberic commented on May 26, 2024

I am having the same issue. Tried adding assembly resolve to app.config, also tried with AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; and still I get that error.

I am running net472 console app which references .netstandard2.0 project which contains the code for querying data.

from microsoft.sqlserver.types.

dotMorten avatar dotMorten commented on May 26, 2024

I am running net472 console app

Do not use this library if you use .NET Framework, but instead use the official Microsoft SDK. This library here is to fill the gap for .NET Core and Xamarin developers.

from microsoft.sqlserver.types.

dejanberic avatar dejanberic commented on May 26, 2024

I am having an issue where I have a lot of apps (WebApps, Console, Azure Cloud Services, Azure Functions) which needed to be converted to .NET 6.
Now, all of them reference my DB class library, and I wanted to migrate to .NET 6 in small steps, one app at a time, where my DB class library and all other class libraries would target .netstandard2.0 except those main apps (web, console etc.).

How can I migrate in steps while using the official Microsoft SDK and targeting .netstandard2.0?

from microsoft.sqlserver.types.

dotMorten avatar dotMorten commented on May 26, 2024

I’d recommend multi targeting your class library instead

from microsoft.sqlserver.types.

dejanberic avatar dejanberic commented on May 26, 2024

Thanks, it works when I multitargeted to net472 and net6.0.

from microsoft.sqlserver.types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.