4

According to SqlServerTypes README I need to put this line:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

before doing spatial operations for a desktop application (mine is a console app).

However it outputs an error on build:

'Utilities' is inaccessible due to its protection level

I went into the packages folder and found Loader.cs and the Utilities class is in fact internal? How would this have ever worked? I couldn't find anyone else with this problem and they are using it with no problems.

Utilities

If I F12 into the decompiled Utilities it is also marked as internal.

SqlServerTypes

I am using version 11.0.2.

Kevin Lee
  • 1,104
  • 3
  • 13
  • 33
  • I have exactly the same. I used the nuget package `https://www.nuget.org/packages/Microsoft.SqlServer.Types/` and have the same thing. Have you found a solution yet? Changing the internal to public did not fix it for me. Seems to keep crashing on the `Application_Start`. – JP Hellemons Oct 31 '16 at 09:48
  • 1
    @JPHellemons Well I did a hack around it. The problem with the package still exists. Since the DLL files are still copied to the output bin directory just not in the root director, I added a post-deployment script to copy the DLL script from the subdirectory to the root bin directory. Since there's no way of differentiating between 32 and 64-bit needs, you can only ever copy one or the other, which might not work for you. I know I will always use the 64-bit version. – Kevin Lee Oct 31 '16 at 10:44
  • 1
    I see things like this as proof-positive that nobody at Microsoft eats the dog-food when it comes to SqlClr or any of Sql Server's peripheral tools. – Pxtl Nov 16 '16 at 22:35
  • This [answer](https://stackoverflow.com/a/39589720/210916) has a workaround to using SqlServerTypes.Utilities, by changing assembly bindings in app.config (or web.config). – MPelletier Jun 22 '18 at 18:43

1 Answers1

0

Installing the nuget package to the MVC site as well as the domain layer fixed this issue for me. To begin with I only installed the package in the domain layer, where I actually use it.

kbjorn
  • 13
  • 2